0

Can someone please explain why one uses this client.setReadTimeOut and client.setConnectTimeOut timeouts? I am using the same with my Jersey client. I have set a timeout of 5 secs for both connect and read. And for testing purpose I have put a thread sleep in my service for 6 secs. I get a timeout exception but after that my service resumes and gives response as normal. My requirement is to set a timeout for the service to respond and if it is passed it should come out and try again. Also I need to set number of attempts the client should try to connect. Please suggest

Sandiip Boa
  • 1
  • 1
  • 3

1 Answers1

0

You client times out after 5 seconds not having heard back from the server and throws a timeout exception as designed. It has no idea whether the server started processing the call or will later on.

When you server wakes up from its sleep, it also has no idea the client timed out. You could check the status of the connection but it'd not be very reliable.

You client may catch the timeout exception and retry the call as many time as you wish. If your concern is about the same server call being executed more than once, then you have to implement you resource method to be idempotent.

TheArchitect
  • 2,161
  • 1
  • 12
  • 16