hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: HttpClient 3.1 / JavaHttp TIME_WAIT differences
Date Fri, 07 Dec 2007 09:18:10 GMT

On Thu, 2007-12-06 at 16:56 +0000, sebb wrote:
> On 06/12/2007, sebb <sebbaz@gmail.com> wrote:
> > On 06/12/2007, sebb <sebbaz@gmail.com> wrote:
> > > On 06/12/2007, Roland Weber <ossfwot@dubioso.net> wrote:
> > > > Hi Sebastian,
> > > >
> > > > > If HttpClient (or my app) is failing to close sockets at the end,
> > > > > perhaps it needs to be enhanced - otherwise it will be causing the
> > > > > server to go into TIME_WAIT instead?
> > > >
> > > > I'm not sure whether the server needs to go into TIME_WAIT
> > > > if it gets a reset packet. But it can't hurt to call
> > > > SimpleHttpConnectionManager.shutdown() when exiting
> > > > the application.
> > >
> > > Oops I forgot:
> > > JMeter 2.3.1 calls closeIdleConnections(-1000) in the threadFinished() code.
> > >
> > > The latest (unreleased) code calls shutdown() instead.
> > >
> > > I'll add that to the test application and see if it helps.
> >
> > That seems to have solved it:
> >
> > With the added shutdown() call in the test app, HttpClient now behaves
> > the same as Java, i.e. the connections to google.com and .co.uk are
> > both left in TIME_WAIT state if keep-alive is selected, but not if
> > keep-alive is not.
> >
> > So your analysis was spot on.
> >
> > Thanks for all the replies.
> 
> Just for completeness, I've also tried running the test application
> without the Java disconnect(). It behaves the same as HttpClient, i.e.
> the google.com connection goes to TIME_WAIT and the final .co.uk
> connection disappears. With disconnect(), Java leaves both connections
> in TIME_WAIT state.
> 
> So in order to ensure an orderly closure, "Java" users should call
> disconnect(), and HttpClient users should call shutdown() before
> exitting.
> 
> When using keep-alive, this will result in TIME_WAITs on the client;
> if not using keep-alive the client does not see TIME_WAIT (because the
> server will have disconnected first).
> 
> I hope that's now the full story ;-)
> 

It would be nice to put all this information into a connection
management guide of some kind or a FAQ.

Oleg

> > > > Looks like we forgot to add that method
> > > > to the interface, but it's too late for 3.1 now.
> > >
> > > I noticed that. Perhaps worth a Jira in case a bugfix release is needed?
> > >
> > > > I wouldn't want to mess with shutdown hooks [1] by default,
> > > > but I will remember the problem when we start working on
> > > > an HttpClient 4.0 Tutorial.
> > >
> > > Maybe add a shutdown method to the HttpClient API?
> > > [Perhaps that exists anyway]
> > >
> > > In 3.1, one has to get the conn manager and check if it is one of the
> > > mgrs that supports shutdown.
> > >
> > > > cheers,
> > > >  Roland
> > > >
> > > > [1]
> > > > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> > > >
> > > >
> > >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message