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 Oz Levanon <Oz...@mobixell.com> on 2009/06/30 15:34:11 UTC

Connection Reset as a Proxy

Hi.

I'm writing a server that acts as an HTTP Proxy, and I connect to the
web using HttpClient (version 3.1)

 

>From time to time I'm experiencing "Connection Reset" from the web. I
guess this is because I try to reuse connections I have from previous
requests, and (because too much time has passed), the website close the
TCP connection, or some NAT dropped the TCP connection.

 

My question is how should I solve the problem in HTTP Client?

1.       Should I set the sockets to work in keepAlive, maintaining the
TCP connection? If so, how can I do that (I only found setSoTimeout
methods, not setKeepAlive, and I can't access the socket itself, since
the getSocket() method in HttpConnection are protected)?

2.       Should I avoid using the same connection to a website as a
proxy for different clients? If so, how can I do that (I'm using
MultiThreadedHttpConnectionManager and it has no knowledge of the
clients contacting me)?

3.       Should I add a retry handler for such cases (and will it slow
things down)?

4.       Can I set some "session timeout" so that a socket will not
outlive a preset duration (that way I can set a number low enough for
any NATs on the way)?

5.       Anything else?

 

Thanks in advance,

Oz

 


Re: Connection Reset as a Proxy

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, Jun 30, 2009 at 04:34:11PM +0300, Oz Levanon wrote:
> Hi.
> 
> I'm writing a server that acts as an HTTP Proxy, and I connect to the
> web using HttpClient (version 3.1)
> 
>  
> 
> From time to time I'm experiencing "Connection Reset" from the web. I
> guess this is because I try to reuse connections I have from previous
> requests, and (because too much time has passed), the website close the
> TCP connection, or some NAT dropped the TCP connection.
> 
>  
> 
> My question is how should I solve the problem in HTTP Client?
> 
> 1.       Should I set the sockets to work in keepAlive, maintaining the
> TCP connection? If so, how can I do that (I only found setSoTimeout
> methods, not setKeepAlive, and I can't access the socket itself, since
> the getSocket() method in HttpConnection are protected)?
> 
> 2.       Should I avoid using the same connection to a website as a
> proxy for different clients? If so, how can I do that (I'm using
> MultiThreadedHttpConnectionManager and it has no knowledge of the
> clients contacting me)?
> 
> 3.       Should I add a retry handler for such cases (and will it slow
> things down)?
> 
> 4.       Can I set some "session timeout" so that a socket will not
> outlive a preset duration (that way I can set a number low enough for
> any NATs on the way)?
> 
> 5.       Anything else?
> 

Oz,

Consider upgrading to HttpClient 4.0, which has a vastly improved connection
management API and code. For details see HttpClient tutorial:

http://wiki.apache.org/HttpComponents/HttpClientTutorial

Oleg

>  
> 
> Thanks in advance,
> 
> Oz
> 
>  
> 

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