commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From José Antonio Pérez Testa <japte...@indra.es>
Subject Re: Commons HttpClient: HttpClient#setConnectionTimeout
Date Thu, 24 Feb 2005 07:03:31 GMT
I think is:
client.setTimeout(5000);

Kedar Panse wrote:

> You may want to use socket timeout (setSoTimeout) not http coonection 
> timeout
>
> Kedar
>
> John C Cartwright wrote:
>
>> Hello All,
>>
>> I'm attempting to throw an exception when the connection cannot be 
>> established within 5 seconds (see code excerpt below). However when 
>> the target host is down (doesn't respond to ping), it takes much 
>> longer than 5 seconds before the exception is actually thrown.
>>
>> Can someone point out what I'm doing wrong?
>>
>> Thanks!
>>
>> -- john
>>
>>
>>        HttpClient client = new HttpClient();
>>        HttpMethod method = new GetMethod(url);
>>        client.setConnectionTimeout(5000);  //wait 5 seconds for response
>>        try {
>>            statusCode = client.executeMethod(method);
>>            String responseBody = method.getResponseBodyAsString();
>>        } catch (Exception e){
>>            log.fatal("error reading URL",e);
>>            throw new IllegalStateException ("Error reading URL");
>>        } finally {
>>            method.releaseConnection();
>>        }
>>
>> ---------------------------------------------------------------------
>> 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
>
-------------------------------------------------------------------------------------------------------------------
Este correo electrónico y, en su caso, cualquier fichero anexo al mismo, contiene información
de carácter confidencial exclusivamente dirigida a su destinatario o destinatarios. Queda
prohibida su divulgación, copia o distribución a terceros sin la previa autorización escrita
de Indra. En el caso de haber recibido este correo electrónico por error, se ruega notificar
inmediatamente esta circunstancia mediante reenvío a la dirección electrónica del remitente.

The information in this e-mail and in any attachments is confidential and solely for the attention
and use of the named addressee(s). You are hereby notified that any dissemination, distribution
or copy of this communication is prohibited without the prior written consent of Indra. If
you have received this communication in error, please, notify the sender by reply e-mail

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


Mime
View raw message