hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <ossf...@dubioso.net>
Subject Re: Question about MultiThreadedHttpConnectionManager
Date Fri, 06 Apr 2007 07:25:34 GMT
Hello Tony,

> The issue seems to be that in the middle of an HTTP 1.1
> conversation, the client is opening a second socket to the host and is
> splitting the requests across the two sockets.  Even though all of the
> data is getting to the server, the server is confused by the fact that
> it is now coming in from 2 different connections.

It is perfectly normal for a client application (Browser, HttpClient) to
open more than one connection if requests can be executed simultaneously.
If the server gets confused by that, the server application is broken.
Nevertheless, you can set the "connections per host" limit of the
connection manager to 1, then only one connection will be used and no
requests are executed in parallel.

> 4. proxy does HttpClient.executeMethod( hostConfig, method )

HttpClient has only one default HttpState. A proxy that is serving
multiple clients should maintain a separate HttpState for each
client session, and pass that state in the executeMethod call.
Otherwise, a backend server that uses cookies to trace client
sessions will indeed get confused, because the wrong cookies are
sent back.

> AGENT              PROXY                          HOST
> ------------------------------------------------------
> req ---------------> req on port 1700 ----------->
> resp <-------------- resp <---------------------- resp
> req ---------------> req on port 1701 ----------->
> resp <-------------- resp <---------------------- resp
> req ---------------> req on port 1701 ----------->
> resp <-------------- resp <---------------------- resp
> req ---------------> req on port 1700 ----------->
> resp <-------------- resp <---------------------- resp
> close

If the port number refers to the local port of your proxy,
I don't see a problem here.

> The question I have is about the MultiThreadedHttpConnectionManager.
> Did it used to keep track of the connection it would make subsequent
> requsts on in a ThreadLocal (even though I was calling
> releaseConnection() between requests) possibly and now it now longer
> does that?

No. MTHCM is thread safe, it does not maintain per-thread state.
It does re-use connections if multiple requests are sent to the
same host. Everything except connection state is tracked by one
or more HttpState objects, as mentioned above.

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