On Tue, 2010-06-15 at 18:37 +0200, Laurent Perez wrote:
> 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.
> 

Even if it is a paying client, your client still is wrong.


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

No, it should not. Both HTTP agent and HTTP origin server may close
persistent connections at any time. 

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

In blocking I/O model the only way to find out whether a connection is
still valid is by attempting to read from it.


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

Yes, it will. Connections may become stale for all sorts of reasons,
even if both the client and the server intend to keep them alive
indefinitely.

Oleg


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

Reply via email to