Question

I'm wondering : is it a non-sense to put a timeout on a synchronous web-service call ? I mean, if there is a risk that the server does not respond, I should use an asynchronous call instead, doesn't it ?

(I'm using Jersey)

Thanks !

Was it helpful?

Solution

I'd always advise to set a connection and read timeout on any and all outbound network requests as indefinitely waiting for an answer could eventually consume all your threads and make your app server unresponsive.

In my experience it's no unusual at all to have partners' WS requests not respond withing 60s (which is quite generous).

Handling read timeouts can be tricky for write operations though as you can't tell whether the other system eventually recorded the request or not. In such situation, your partner hopefully provides an idempotent API allowing you to retry at a later time without risk of duplicate execution. Otherwise it may require manual communication with your partner.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top