hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graeme Rouse <gra...@arizonabay.com>
Subject Re: Recovering a connection from an unresponsive host
Date Wed, 08 Nov 2006 21:52:12 GMT
Olaf,

Thank you for the tip. Making this change simplifies my code and best  
of all, makes it work as I expect.

Thanks again for helping me out with this,

Graeme

On 8-Nov-06, at 3:59 AM, Olaf Sebelin wrote:

> Hello Graeme,
>
>
> Graeme Rouse <graeme@arizonabay.com> schrieb am 07.11.2006 um 15:33:
>
> [...]
>>
>> I have been trying to determine how to correctly set the timeout
>> parameters in order to limit the connection time and force the code
>> below to complete within a maximum amount of time.
> [...]
>>
>> my code:
>>
>> final int SOCKET_TIMEOUT = 1000;
>> final int CONNECTION_TIMEOUT = 1000;
>> long start = System.currentTimeMillis();
>>
>> HttpClient httpclient = new HttpClient();
>> GetMethod httpget = new GetMethod( UNREACHABLE_HOST );
>> httpget.getParams().setSoTimeout( SOCKET_TIMEOUT );
>> httpget.getParams().setParameter( "http.connection.timeout",
>> CONNECTION_TIMEOUT );
>
> Try to set the timeout on the connection manager:
>
> httpclient.getHttpConnectionManager().getParams()
>   .setSoTimeout(CONNECTION_TIMEOUT);
>
> or
>
> MultiThreadedHttpConnectionManager connectionManager
>   = new MultiThreadedHttpConnectionManager();
>
> connectionManager.getParams().setConnectionTimeout 
> (CONNECTION_TIMEOUT);
>
> HttpClient httpclient = new HttpClient(connectionManager);
>
>
> Regards,
> Olaf
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user- 
> help@jakarta.apache.org
>


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


Mime
View raw message