Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes URLConnection timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "URLConnection timeout" Watch "URLConnection timeout" New topic
Author

URLConnection timeout

Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

I have a Servlet that processes a request and returns a result (pretty standard stuff). However, the processing that happens can take some time, and I get a "Connection reset by peer" error message before the processing finishes.
I am connection by a URLConnection, and before I get the "Connection reset by peer" error on the server, I get <URL> file not found, thworn from within getInputStream() of the URLConnection.
This does not happen with shorter processes, just the longer ones.
How can I set the timeout value so that my longer processes will finish? We are using Bluestone's Total-e-server (v.7.3) as the app server an IIS as the web server.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
arul senthil
Greenhorn

Joined: Jul 03, 2001
Posts: 29
In your Servlet code, use the "setMaxInactiveInterval(int seconds)" method of the "HttpSession" class to set the Session Timeout Value for your server. The Servlet API says :
public void setMaxInactiveInterval(int interval)
Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.
Parameters:
interval - An integer specifying the number of seconds
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Originally posted by arul senthil:
The Servlet API says :
...between client requests before the servlet container will invalidate this session....

Unfortunately, the problem is not with the length of time between client requests; it is in the length of time between when the client makes a request and gets a response. The client seems to be timing out (the URLConnection), and is disconnecting itself from the server (resulting in the "Connection reset by peer" error message when the server tries to send the response back to the client).
IS there anyway to set the timeout in a java.net.URLConnection?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: URLConnection timeout
 
Similar Threads
(104) Connection reset by peer
Information required regarding SOAPExceptions
SOAP and java.net.SocketException
SocketException
java.net.SocketException