commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Hufgard <>
Subject Re: [commons-httpclient] setConnectionTimeout not working?
Date Tue, 25 Apr 2006 08:03:41 GMT
Hi Alex,

> long startTime = System.currentTimeMillis();
> int resultCode = client.executeMethod(getMethod);
> setConnTime(System.currentTimeMillis()-startTime);

> my connection timeout is set to 1000 (1 second),  output shows that
> connection to some site took over 3-4 seconds and 

> why is it not throwing ConnectTimeoutException?

Well, I guess I made the same wrong assumption you did. Connection
timeout is _not_ an overall timeout for the whole connection. It is a
timeout für getting a connection to the server.
A timeout of 1 second means, that if the server does not accecpt a
connection within one second a ConnectTimeoutException will be thrown.
But as soon as the connection is established, this value is no longer
You can now also set a SocketTimeout which specifies how much time
may be between two bytes coming in and manually setting a read

As far as I know, the httpclient has no support for a read timeout.
In our environment we had some really slow servers. They sent maybe
one byte each second. SocketTimeout was not reached, it was about 30
seconds since the request itself might took some time to process.
So I used a BufferedInputStream, read the data within a loop and
checked for the reading time manually.

Best regards,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message