hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurent Perez <hak...@gmail.com>
Subject Does HttpClient v3 handle Keep-Alive properly ? (code analysis and description inside)
Date Tue, 15 Jun 2010 16:37:48 GMT
Hello

I'm trying to understand if the v3, which my application currently
uses, handles Keep-Alive properly - because our client says it does
not.

On several requests, using lsof, I can see that httpclient connections
in state ESTABLISHED gradually fall back to a CLOSE_WAIT state, and
they also stay in this state, unless I explicitely call
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager#closeIdleConnections.
A question : if Keep-Alive was working properly, should the
connections stay in ESTABLISHED forever ?

By looking at the source,
org.apache.commons.httpclient.HttpMethodBase#shouldCloseConnection
looks correct, we are using HTTP/1.1, it implies connections are
persistent.
However, org.apache.commons.httpclient.HttpConnection#closeIfStale
seems to think connections are staled, hence closing them, so it's not
reusing them. I don't understand the
org.apache.commons.httpclient.HttpConnection#isStale part, with
socket.setSoTimeout(1);/inputStream.mark(1);/inputStream.read() : why
is the timeout set to 1 and how would it affect the read ?

Is the stale checking code broken in v3, breaking connections reuse ?
I've read the Connection keep alive strategy chapter at
http://hc.apache.org/httpcomponents-client/tutorial/html/connmgmt.html,
and I can't figure out if v4 fixes it or not : if v4 assumes it can
keep the connection forever, will it still do a stale check ?

Thanks for your input
laurent


-- 
<a href="http://blog.jdeuxe.info/">http://blog.jdeuxe.info/ - Java
entreprise tips & tricks</a>

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


Mime
View raw message