• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

400 Bad Request when dependent service is down

 
Ranch Hand
Posts: 49
1
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
  • 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: 12270
259
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks for the info. 503 makes sense to me. Thanks!
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic