This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

URLConnection not timing out correctly  RSS feed

 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want my url connection to timeout after a few seconds but it continues to try to connect past the timeout. Has anyone ever seen this before?

I.E.


Is there something going on here that I am missing?

Thanks
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of the JDK are you using?
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just as a confirmation, I have the same problem with my Java 6u13. No matter if I change the timeout to 1s or 5s, after just over 2s the exception is thrown.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see from the Javadoc that non std implementations can ignore this setting and that you should try a getTimeout() after you set it to see the real time out value?
 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried in 1.5 and 1.6 same problem.

I did try getConnectTimeout() just as the javadoc says and I can see the correct value (i.e. whatever I set it to). The problem still remains that it does not timeout properly. Any more ideas?

Thanks again.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't think of anything else no, I can only assume the underlying resource is not playing ball so to speak .
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to move this to our sockets forum, perhaps somebody there can help you better.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!