You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Tom van den Berge <to...@bibit.com> on 2004/11/19 11:00:36 UTC

[HttpClient] Lifetime of an unused connection

Hi,

When using a MultiThreadedHttpConnectionManager for an HttpClient, 
connections that are used and released again are placed back in the pool 
again, so they can be reused. I was wondering for how long unused 
connections will remain in the pool. In other words, what is causing a 
connection to be removed from the pool?

I can imagine it might be caused by the read timeout of the socket, or 
there may be a separate 'keep alive' setting? Also the remote host might 
terminate the connection after some time, and how does that influence 
the connection object in the pool?

I'm talking about httpclient 2.0.2.

Thanks,
Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [HttpClient] Lifetime of an unused connection

Posted by Oleg Kalnichevski <ol...@apache.org>.
Tom,

HttpClient 2.0.x does not implement any connection eviction policy.
Connections are kept in the pool indefinitely. HttpClient 3.0 does
provide a mechanism to control the lifetime of persistent connections.
It should be fairly trivial to implement a custom connection eviction
policy on top of it:

http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/commons/httpclient/HttpConnectionManager.html#closeIdleConnections(long)
http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.html

Hope this clarifies things a little

Oleg

On Fri, Nov 19, 2004 at 11:00:36AM +0100, Tom van den Berge wrote:
> Hi,
> 
> When using a MultiThreadedHttpConnectionManager for an HttpClient, 
> connections that are used and released again are placed back in the pool 
> again, so they can be reused. I was wondering for how long unused 
> connections will remain in the pool. In other words, what is causing a 
> connection to be removed from the pool?
> 
> I can imagine it might be caused by the read timeout of the socket, or 
> there may be a separate 'keep alive' setting? Also the remote host might 
> terminate the connection after some time, and how does that influence 
> the connection object in the pool?
> 
> I'm talking about httpclient 2.0.2.
> 
> Thanks,
> Tom
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [HttpClient] Lifetime of an unused connection

Posted by Michael Becke <be...@u.washington.edu>.
Hi Tom,

In HttpClient 2.0 connections are never closed/deleted from a  
MultiThreadedHttpConnectionManager until it is shutdown.  Things like  
keep-alive settings and exceptions will cause connections to be closed,  
but they will still be returned to the connection manager.

HttpClient 3.0 (just about to be 3.0 beta1) adds the ability to close  
idle connections.  Have a look at the following for some more details:

<http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/ 
commons/httpclient/ 
MultiThreadedHttpConnectionManager.html#closeIdleConnections(long)>

and

<http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/ 
commons/httpclient/util/IdleConnectionTimeoutThread.html>

Mike

On Nov 19, 2004, at 5:00 AM, Tom van den Berge wrote:

> Hi,
>
> When using a MultiThreadedHttpConnectionManager for an HttpClient,  
> connections that are used and released again are placed back in the  
> pool again, so they can be reused. I was wondering for how long unused  
> connections will remain in the pool. In other words, what is causing a  
> connection to be removed from the pool?
>
> I can imagine it might be caused by the read timeout of the socket, or  
> there may be a separate 'keep alive' setting? Also the remote host  
> might terminate the connection after some time, and how does that  
> influence the connection object in the pool?
>
> I'm talking about httpclient 2.0.2.
>
> Thanks,
> Tom
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org