Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLConnection timeout

 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
arul senthil
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic