• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

400 Bad Request when dependent service is down

 
Ranch Hand
Posts: 46
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: 12027
257
  • 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: 46
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!
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic