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 Ken Krugler <kk...@transpac.com> on 2009/07/08 00:48:57 UTC

Proper handling of stale connections

Hi there,

I wanted to confirm that I'm handling stale connections 
appropriately, so any input is appreciated.

I've got a test configuration where embedded Jetty is handling the 
HTTP requests, and I've turned off stale connection checks on the 
client side.

I'm using httpcore-4.0.1 and httpclient-4.0-beta2. I know, the rc1 
version of the client is available, but not via the Maven central 
repo.

First, I'm assuming that when I try to reuse a stale connection, what 
I'll get is a SocketException. Not that I'm counting on this, but 
it's the behavior I see with my test setup.

Second, I really only want to retry the request when I get an 
IOException. And that there's no point in retrying more than once.

Thanks,

-- Ken
-- 
Ken Krugler
+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


Re: Proper handling of stale connections

Posted by Oleg Kalnichevski <ol...@apache.org>.
Ken Krugler wrote:
> Hi there,
> 
> I wanted to confirm that I'm handling stale connections appropriately, 
> so any input is appreciated.
> 
> I've got a test configuration where embedded Jetty is handling the HTTP 
> requests, and I've turned off stale connection checks on the client side.
> 
> I'm using httpcore-4.0.1 and httpclient-4.0-beta2. I know, the rc1 
> version of the client is available, but not via the Maven central repo.
> 
> First, I'm assuming that when I try to reuse a stale connection, what 
> I'll get is a SocketException. Not that I'm counting on this, but it's 
> the behavior I see with my test setup.
> 

Ken,

Yes, this is correct.


> Second, I really only want to retry the request when I get an 
> IOException. And that there's no point in retrying more than once.
> 

I think the best way to do so is by providing a custom 
HttpRequestRetryHandler. For details see:

http://hc.apache.org/httpcomponents-client/tutorial/html/fundamentals.html#d4e246
http://hc.apache.org/httpcomponents-client/tutorial/html/fundamentals.html#d4e280

Hope this helps

Oleg

> Thanks,
> 
> -- Ken


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