commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dylan Stamat <dyl...@gmail.com>
Subject Re: Commons HttpClient: HttpClient#setConnectionTimeout
Date Wed, 23 Feb 2005 20:54:33 GMT
Hello John !

5000 millis is 83 seconds... correct ?
I think you want to use 300 as the value instead.

My math or conversion may be way off, but I think this is it :)
Let me know !
==
Dylan



On Wed, 23 Feb 2005 12:58:46 -0700, John C Cartwright
<John.C.Cartwright@noaa.gov> 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


Mime
View raw message