commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Dever" <jdev...@nortelnetworks.com>
Subject RE: [HttpClient] Automatic reconnect in case of closed connection .
Date Wed, 18 Sep 2002 16:15:06 GMT

This seems reasonable to me.

> -----Original Message-----
> From: Elwin, Martin [mailto:melwin@rsasecurity.com]
> Sent: Wednesday, September 18, 2002 6:55 AM
> To: Jakarta Commons Developers List
> Subject: [HttpClient] Automatic reconnect in case of closed 
> connection.
> 
> 
> Hi all,
> 
> Please let me run this by you and let me know what you think 
> (like if I'm
> completely out of line, or not...)...
> 
> When using a web server (or proxy server) that closes the http (1.1)
> connections after a certain timeout (almost all do - for instance, the
> Apache Httpd does it after 15 seconds by default) a write to the
> HttpConnection will fail with an IOException (or 
> SocketException rather). I
> believe that the correct thing for the HttpClient to do is to 
> reconnect the
> closed socket (_once_) and try to do the request again. The 
> reason being, a
> by the server closed socket should not be a problem when 
> doing a request,
> and therefore the HttpClient should try to establish the 
> socket again and
> try to make the request. BUT, if something goes wrong, like 
> with the opening
> of the connection or similar, a retry should not be made but rather an
> exception should be thrown (the way it is now) to signal the 
> problem to the
> application using the HttpClient library.
> 
> ---
> 
> Example code modification to HttpMethodBase.java:
> 
> in the execute(..) method, change the line:
> 
>       processRequest(state, conn);
> 
> 
> to:
> 
> 	try {
>             processRequest(state, conn);
> 	}
> 	catch(IOException ioe) {
>             if (log.isDebugEnabled()) {
>                 log.debug("Socket closed? Trying to reestablish
> connection");
>             }
> 		conn.close();
>             processRequest(state, conn);
> 	}
> 
> ---
> 
> Do you think this is bad, and if that's the case, why? I've 
> been using the
> above change in my application to handle sockets closed by 
> the Apache Httpd
> configured as a forward proxy. Internally it might be wise to 
> subclass (or
> wrap) IOException so that the above case can be detected with better
> certainty, instead of catching the, when it comes to streams, 
> pretty generic
> IOException...
> 
> Regards,
> 
> /M
> 
> ------------
> Martin Elwin
> @N59.29606 E18.08052 (WGS-84)
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:commons-dev-help@jakarta.apache.org>
> 
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message