hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ossf...@dubioso.net
Subject RE: HttpClient 3.1 / JavaHttp TIME_WAIT differences
Date Thu, 06 Dec 2007 12:49:05 GMT
Hi Sebastian,

shooting from the hip...

The TIME_WAIT state indicates that the connection
was orderly closed. If a connection (of HttpClient)
remains open when the JVM exits, it is force-closed
by a reset and does not enter the TIME_WAIT state.

> Example 4: http://www.google.com/ auto-redirect=true, keep-alive=true
> [Redirects to www.google.co.uk]
> 
> HttpClient leaves a connection to www.google.com in TIME_WAIT
> Java leaves connections to both www.google.com and www.google.co.uk in 
> TIME_WAIT

HttpClient connects to www.google.com and receives
a redirect. The method director returns the open
connection to the SimpleHttpConnectionManager, which
consumes the response body. The socket is kept open
until the method director obtains the connection for
the redirect. Then it is orderly closed, bringing it
into TIME_WAIT state. A new socket is used to read
from www.google.co.uk. Because of the keep-alive,
that socket remains open until the JVM exits.

Explaining the behavior of Java HTTP is a bit
trickier. Either their keep-alive strategy closes
sockets that HttpClient keeps open, or they use
a shutdown hook to orderly close connections when
the JVM exits.

Does that make sense? It might play a role whether
the connection is closed by the client (HttpClient+
redirect) or by the server ("connection: close" in
the request you send).

You may want to use MultiThreadedHttpConnectionManager
to get results that are better comparable.

hope that helps,
  Roland

---------------------------------------------------------------------
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