You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by bnijjhar <ba...@accenture.com> on 2011/07/04 11:17:47 UTC

Is it good practice to set the connection timeout for ThreadSafeClientConnManager implementation?

Hi
I've set the socket timeout for my DefaultHttpClient 4.1.1. However, I'm
unsure whether to set the connection timeout. It seems that for an
HttpClient using the ThreadSafeClientConnManager, the threads are
effectively waiting for a connection from the connection manager's pool
(rather than whether the connection has been established). So if the
connection manager does not manage to establish the connection within the
connection timeout (e.g. 100 ms) for the first thread, then the second
thread which might have been waiting from about the same time as the first
thread, receives a timeout almost immediately (instead of the connection
manager trying again and giving a timeout 100 ms later). I feel that if the
size of the connection pool was not tuned carefully, or there was a sudden
peak in threads, this would result in threads being timed out just because
threads before them were timing out also.
Does anyone have any advice? In HttpClient 3.1, there seemed to be two sets
of parameters, one for the connection manager to establish the connection,
and one for the HttpClient to get a connection from the connection manager
(as described in this link
http://brian.olore.net/wp/2009/08/apache-httpclient-timeout/) and I think I
just want the former?
-- 
View this message in context: http://old.nabble.com/Is-it-good-practice-to-set-the-connection-timeout-for-ThreadSafeClientConnManager-implementation--tp31987905p31987905.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: Is it good practice to set the connection timeout for ThreadSafeClientConnManager implementation?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2011-07-04 at 02:17 -0700, bnijjhar wrote:
> Hi
> I've set the socket timeout for my DefaultHttpClient 4.1.1. However, I'm
> unsure whether to set the connection timeout.

You should.

>  It seems that for an
> HttpClient using the ThreadSafeClientConnManager, the threads are
> effectively waiting for a connection from the connection manager's pool
> (rather than whether the connection has been established). So if the
> connection manager does not manage to establish the connection within the
> connection timeout (e.g. 100 ms) for the first thread, then the second
> thread which might have been waiting from about the same time as the first
> thread, receives a timeout almost immediately (instead of the connection
> manager trying again and giving a timeout 100 ms later). 

The connect timeout for all threads would be the same (100 ms)
regardless of how long it took to lease the connection from the pool.

Hope this helps

Oleg 



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