简体   繁体   中英

JAX-WS timeout problem

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 ?

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 .

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.

eg 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM