Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problem setting connection timeout in java.netURLConnection

843790Jan 4 2007 — edited Jan 8 2007
I 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 5 2007
Added on Jan 4 2007
3 comments
303 views