commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kenny Smith <tomcat-u...@journalscape.com>
Subject Re: [httpclient] How to determine if connection is alive?
Date Tue, 25 Mar 2003 00:04:30 GMT
Thanks for the response, Adrian. That is a total bummer! I was able to 
hack together two or three tests that can be used to logically derive my 
original test, so it's hackish, but at least we were able to verify 
funtionality.

Thanks again!
Kenny Smith

Adrian Sutton wrote:
> Hi Kenny,
> I think you're in for a world of hurt. :)  The main reason I say this is
> because Java doesn't provide any method to determine if a connection is
> still open (even the 1.4 method isOpen doesn't work if the remote server
> closes the connection due to time out).  The isAlive() method in
> HttpConnection suffers the same problem.
> 
> Now, if apache requests that the connection is closed immediately, it will
> return a "Connection: close" header which you can retrieve via the
> getResponseHeader method on the HttpMethod you executed.  You might also run
> into a Proxy-Connection: close header.  Take a look at the source for the
> HttpMethodBase.shouldCloseConnection() method to be sure you get all the
> possible conditions (I'd be tempted to either just copy the method and tweak
> it a little or extend whichever actual HttpMethod implementation your using
> to make it public).
> 
> The above solution is rather hackish, but should get you going anyway.
> 
> Regards,
> 
> Adrian Sutton, Software Engineer
> Ephox Corporation
> www.ephox.com
> 
> 
> -----Original Message-----
> From: Kenny Smith [mailto:tomcat-user@journalscape.com]
> Sent: Tuesday, 25 March 2003 5:13 AM
> To: commons-user@jakarta.apache.org
> Subject: [httpclient] How to determine if connection is alive?
> 
> 
> Hello,
> 
> I'm currently using 2.0a1 (I can't upgrade to the current release yet 
> for production reasons) and I'm using Keep-Alive connections. I would 
> like to find out if my connection is still alive, but I can't find any 
> way to determine that. I've found the isAlive() method in HttpConnection 
> object, but I can't find anyway to get an instance of the HttpConnection 
> object.
> 
> My overall goal: We are testing an application where apache will have 
> Keep-Alives turned off. My testing app will use HttpClient to try to 
> create a Keep-Alive connection and hold it open as long as possible. In 
> the previous version, the thread making the request would just sleep for 
> x number of seconds, but I want the code to move ahead and make the next 
> request if apache forces the connection closed (i.e. correctly stops the 
> Keep-Alive) so simply sleeping x number of seconds blindly doesn't work 
> for me.
> 
> Any help is appreciated, thanks!
> Kenny Smith
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 



Mime
View raw message