• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

400 Bad Request when dependent service is down

 
Ranch Hand
Posts: 49
1
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lets say I have service A which depends on service B. When service B is down service A returns 400 Bad Request when posting an object. Is this correct behavior? My worry is that this is misleading. There is nothing wrong with the request it just can't be processed because service B is down. Is there a better return code that would inform the user of this?
 
Saloon Keeper
Posts: 14711
331
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right, HTTP 4xx status codes are not appropriate for errors that are not caused by the client.

You should return an HTTP 5xx status code. Either "502 Bad Gateway" or "503 Service Unavailable" seems appropriate to me, depending on whether service A just acts as a proxy for service B.

If you don't want to disclose a specific reason, you can also return "500 Internal Server Error".
 
John Mercier
Ranch Hand
Posts: 49
1
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the info. 503 makes sense to me. Thanks!
 
reply
    Bookmark Topic Watch Topic
  • New Topic