Shivani Gauryan
Shivani Gauryan

Reputation: 103

Difference between web service connection timeout and request timeout

WebClientTestService service = new WebClientTestService() ;
int connectionTimeOutInMs = 5000;
Map<String,Object> context=((BindingProvider)service).getRequestContext();
context.put("com.sun.xml.internal.ws.connect.timeout", connectionTimeOutInMs);
context.put("com.sun.xml.internal.ws.request.timeout", connectionTimeOutInMs);
context.put("com.sun.xml.ws.request.timeout", connectionTimeOutInMs);
context.put("com.sun.xml.ws.connect.timeout", connectionTimeOutInMs);

Please share the differences mainly in connect timeout and request timeout.

I need to know the recommended values for these parameter values.

What are the criteria for setting timeout value ?

Upvotes: 7

Views: 6194

Answers (1)

shnplr
shnplr

Reputation: 230

Please share the differences mainly in connect timeout and request timeout.

I need to know the recommended values for these parameter values.

  • Connect timeout (10s-30s): How long to wait to make an initial connection e.g. if service is currently unavailable.
  • Socket timeout (10s-20s): How long to wait if the service stops responding after data is sent.
  • Request timeout (30s-300s): How long to wait for the entire request to complete.

What are the criteria for setting timeout value ?

It depends a web user will get impatient if nothing has happened after 1-2 minutes, however a back end request could be allowed to run longer.

Also consider server resources are not released until request completes (or times out) - so if you have too many requests and long timeouts your server could run out of resources and be unable to service further requests.

request timeout should be set to a value greater then the expected time for the request to complete, perhaps with some room to allow occasionally slower performance under heavy loads.

connect/socket timeouts are often set lower as normally indicate a server problem where waiting another 10-15s usually won't resolve.

Upvotes: 9

Related Questions