hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony Thompson" <Tony.Thomp...@stone-ware.com>
Subject Question about MultiThreadedHttpConnectionManager
Date Wed, 04 Apr 2007 18:46:42 GMT
First a little background on my application.  I have a proxy application
that accepts requests from an HTTP user agent and then uses the Apache
HttpClient to facilitate passing that request to a particular host.  I
had been using the 2.0.2 version of the HttpClient and everything was
working perfectly.  Recently I upgraded my code to the 3.0.1 version of
the HttpClient and I have noticed a weird little issue.  I am using the
MultiThreadedHttpConnectionManager and I think the issue I am having is
in there but I am not sure.

So, a little info on the issue that I am seeing.  With the 3.0.1 client,
my application works fine for a bit.  Seems like it works OK until a
certain amount of data is moved through it or something.  I have been
unable to track down why it works and then stops working.  I have done
some packet traces of the client in a working state and when it is
broken.  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.  I suppose it could be
an issue with the way I am using the client but, I am confused why it
worked perfectly with the 2.0.2 client and works for a bit with the
3.0.1 client before it breaks.

Here are the basic steps I go through in my code for one HTTP request:
1. agent submits request
2. proxy gets the request and creates an HttpMethod
3. proxy determines what host to submit the request and gets a
HostConfiguration for that host
4. proxy does HttpClient.executeMethod( hostConfig, method )
5. response is processed and proxy calls method.releaseConnection()
.....
n. connection is closed between agent and proxy

So, steps 1 - 5 are executed several times:

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

When the conversation breaks:

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

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?  That is speculation on my part but like I said, I can't
explain why it worked in 2.0.2 and why now it thinks it needs to open
another connection at some point during that conversation.

If anyone was able to make sense of my long email and has any input, I
would appreciate it.
Tony
 
This message (and any associated files) is intended only for the 
use of the individual or entity to which it is addressed and may 
contain information that is confidential, subject to copyright or
constitutes a trade secret. If you are not the intended recipient 
you are hereby notified that any dissemination, copying or 
distribution of this message, or files associated with this message, 
is strictly prohibited. If you have received this message in error, 
please notify us immediately by replying to the message and deleting 
it from your computer. Messages sent to and from Stoneware, Inc.
may be monitored.

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