2

I am trying to set connect and request timeout for a JAX WS and Http Post calls. My code works, but only a maximum of 20 seconds. That is I can change the timeout value to 5 seconds, 2 seconds, it works, but setting the timeout value to 30 seconds will time out at 20 seconds, setting the time out value to 60 seconds will still timeout at 20 seconds. Does anybody know where is that maximum of 20 seconds set??

For JAXWS:

//This works, timed out in 10 seconds
((BindingProvider) soapPort).getRequestContext().put(JAXWSProperties.CONNECT_TIMEOUT, 10000);

// This would time out in 20 seconds!!!
((BindingProvider) soapPort).getRequestContext().put(JAXWSProperties.CONNECT_TIMEOUT, 60000);`

For Http:

// This works, timed out in 10 seconds
HttpConnectionParams.setConnectionTimeout(params, 10000);

// This would time out in 20 seconds!!!
HttpConnectionParams.setConnectionTimeout(params, 50000);
elefant
  • 73
  • 7

1 Answers1

0

The default JAX-WS runtime for Glassfish is Metro 2.0. See the 5.6. HTTP Timeouts section in the Metro guide, so we have:

// setConnectTimeout()
int timeout = ...;
Map<String, Object> ctxt = ((BindingProvider)proxy).getRequestContext();
ctxt.put(JAXWSProperties.CONNECT_TIMEOUT, timeout);

// setReadTimeout()
int timeout = ...;
Map<String, Object> ctxt = ((BindingProvider)proxy).getRequestContext();
ctxt.put("com.sun.xml.ws.request.timeout", timeout);

Only as a guide, you can see that there are three parameters for Websphere (in Metro 2.0 only two), which are:

  1. CONNECTION_TIMEOUT: The amount of time WebSphere JAX-WS client would wait to establish a http/https connection (default is 180 seconds)
  2. WRITE_TIMEOUT: The amount of time the client would wait to finish sending the request (default is 300 seconds)
  3. RESPONSE_TIMEOUT: The amount of time the client would wait to finish receiving the response (default is 300 seconds)
Paul Vargas
  • 41,222
  • 15
  • 102
  • 148
  • Thanks Paul, I have tried adding the read time out too, and it didn't make any difference. I suspect the 20 secs could be the firewall timeout. – elefant Mar 27 '13 at 22:18
  • You can do a little local test with [JAX-WS Hello World Example](http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example-document-style/), but put a `Thread.sleep(1000*seconds);` before return the greeting string. The standard JDK use Metro as JAX-WS runtime. – Paul Vargas Mar 27 '13 at 22:43