Classification: For internal use only 

Oleg/Sam,

Thanks a lot for both your help! The issue is now resolved.

Question though is why does the logs show that the connection is reusable, 
getting free connection etc when in fact it is opening a new socket?

DEBUG 03:07:03.490 - 08/09/2011 [pool-1-thread-43] [] 
o.a.h.i.c.t.ConnPoolByRoute - [HttpRoute[{s https://xxxx.intranet.com:410]] 
total kept alive: 10, total issued: 0, total allocated: 10 out of 10 DEBUG 
03:07:03.490 - 08/09/2011 [pool-1-thread-43] [] 
o.a.h.i.c.DefaultClientConnection - Connection closed DEBUG 03:07:03.490 - 
08/09/2011 [pool-1-thread-43] [] o.a.h.i.c.t.ConnPoolByRoute - Getting free 
connection [HttpRoute[{s}->https://xxxx.intranet.com:410]][null]


Should there not be a debug statement in there that says "Cannot find free 
connection with context [null], creating a new one"

I think this would make things more clear.

Thanks,
____________________________________________________


Thomas Kunnumpurath




-----Original Message-----
From: Oleg Kalnichevski [mailto:[email protected]]
Sent: Thursday, September 08, 2011 12:08 PM
To: HttpClient User Discussion
Subject: Re: ThreadSafeClientConnectionManager and KeepAlive connnections [I]

On Thu, 2011-09-08 at 16:06 +0100, Sam Crawford wrote:
> I've not used the UserToken class myself (and don't have a readily 
> available test environment), but if the approach you've got isn't 
> working (what do the ConnPoolByRoute logs show?) then from reading the 
> docs I'd suggest you have two options:
> 
> 1. Do it as per 7.2.2.1 on
> http://hc.apache.org/httpcomponents-client-ga/tutorial/html/advanced.html.
> i.e. Run the first request without setting the UserToken, pull it from 
> the context after the response, and then reuse it forever more.
> 2. Reuse the same HttpContext across all requests (although you'll 
> want to be careful in a multi-threaded setup of course).
> 
> Thanks,
> 
> Sam
> 

Thomas and Sam,

It is all quite simple. There is no way of knowing for HttpClient that requests 
are logically related and share the same user identity per default. One must 
use the _same_ HttpContext instance in order to inform HttpClient that requests 
are logically related and belong to the same user. Once a user token is bound 
to the context HttpClient will automatically use the token when obtaining 
connections from the pool.
Without the token the pool manager cannot lease connections that carry a state 
and will have to create a new connection instead of re-using persistent 
connections from the pool.

Hope this helps

Oleg 




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---
This communication may contain confidential and/or privileged information. If 
you are not the intended recipient (or have received this communication in 
error) please notify the sender immediately and destroy this communication. Any 
unauthorized copying, disclosure or distribution of the material in this 
communication is strictly forbidden.
Deutsche Bank does not render legal or tax advice, and the information 
contained in this communication should not be regarded as such.

Reply via email to