problem setting connection timeout in java.netURLConnection
843790Jan 4 2007 — edited Jan 8 2007I am trying to set the connection timeout of a java.net.HttpURLConnection object using the setConnectTimeout method inherited from its parent java.netURLConnection.
Here is the timeouts i get for different settings:
- negative timeout - throws exception as expected
- 0 seconds - it timeouts in about 20 seconds while it should wait for infinite time
- more than 0 but less than 20 seconds - it works as expected
- more than 20 seconds - it always timeouts in about 20 seconds
When run these steps against a server which drops the connection i get the error:
java.net.ConnectException: Connection timed out: connect
When run these steps against a server which rejects the connection i get the error:
java.net.SocketException: Connection reset by peer: connect
Any help will be appreciated, thanks.