views:

595

answers:

3

I've published web service endpoint on Sun light weight http server. The server is running with ThreadPool executors for the connection (Executors.newCachedThreadPool()). I'm also using regular web service client (also JAX-WS).

It seems that for every call that exceed 5 minutes the server (or the client) ends the current call thread and open a new one. In the server it looks like a new connection was established and trying to run the same action.

This only happens once, meaning the "second call" might exceed 5 minutes.

Is there a default timeout for a connection ? Is there a way to configure it ?

+1  A: 

I would normally expect this to be a client-side issue (however - check Pascal's answer). The clients will have a defined timeout value and would bail out on an operation taking too long.

e.g. in HttpClient you can define the connection timeout, and the read timeouts separately (see the configuration guide).

If the method truly takes 5 mins or more, I would look at how to break that operation down into more discrete operations, each taking a shorter period of time. Or do the processing in the background, and give the client a ticket such that they can receive their results at a later time without maintaining a connection.

Alternatively, you may be able to set an infinite timeout, but I wouldn't recommend this, since your client ideally should be able to identify when your server isn't responding due to problems/misconfiguration etc.

Brian Agnew
You can also define timeout properties for the web service client that I'm using:Map<String, Object> requestContext = bp.getRequestContext(); requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, <int time>);requestContext.put(JAXWSProperties.REQUEST_TIMEOUT, <int time>);However, this didn't help.
Tal
@Brian This is actually not a client-side issue.
Pascal Thivent
@Pascal - noted (I've not looked at your links provided yet). Do you know if Jetty doesn't bail on idle connections in a similar fashion ? Note that I've edited my answer appropriately (!) but I think for a 5 min operation, the issue of client timeout will come into play at some stage, hence I've not deleted it.
Brian Agnew
@Tal The *default* timeout of a JAX-WS client is `0` (infinite).
Pascal Thivent
Interesting. Note my comments above re. infinite timeouts.
Brian Agnew
@Brian Hmm... Good question about Jetty, not 100% sure, need to check that. Now, I totally agree that it would be a good thing to set a finite client timeout (and to not use the "infinite" default) anyway.
Pascal Thivent
+3  A: 

With the light weight http server, a connection would become idle after 5 mn. The implementation (have a look at ServerImpl and ServerConfig) closes the idle connections and there is currently no public property to set this idle timeout. If you want this kind of control, you may want to use a servlet container. Or you could use Jetty (which provides a SPI) instead of Sun default HttpServer.

Pascal Thivent
A: 

Actually I was able to find a hack by using the information that Pascal provided (Thanks !). You could override the idle time of the http server by setting a system property -sun.net.httpserver.idleInterval.

Tal