hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: When to use ConnectionKeepAliveStrategy
Date Tue, 04 Aug 2009 09:30:36 GMT
On Mon, Aug 03, 2009 at 03:33:30PM -0700, Ken Krugler wrote:
> Hi all,
>
> On http://hc.apache.org/httpcomponents-client/tutorial/html/ch02.html  
> the section titled "Connection keep alive strategy" talks about when to 
> implement a custom keep-alive strategy.
>
> But I thought that if a connection gets dropped by the server due to  
> inactivity, the next request made using that stale connection will  
> trigger an IOException, which HttpClient will automatically handle by  
> re-trying with a new connection.
>
> So is the issue that retrying winds up being less efficient, versus  
> auto-closing connections? Or is my understanding of what HttpClient 4  
> will do with a stale connection too optimistic?
>
> Thanks,
>
> -- Ken
>
>

Ken,

It is not necessarily less efficient but some folks just do not like the idea
of getting an exception. Besides, if combined with a watcher thread evicting
expired connection from the pool, ConnectionKeepAliveStrategy helps ensure
connections get closed as they expire, instead of sitting in the pool
indefinitely waiting for a request to be made. 

Overall, it just makes things cleaner.

Oleg


> --------------------------
> Ken Krugler
> TransPac Software, Inc.
> <http://www.transpac.com>
> +1 530-210-6378
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>

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


Mime
View raw message