• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why settimeout is not working?  RSS feed

 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why set setConnectTimeout(100) is not working.

It is throwing only

java.net.UnknownHostException: google.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at sun.net.NetworkClient.doConnect(NetworkClient.java:158)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:837)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:778)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:703)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1026)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
at Test.connect(Test.java:16)
at Test.main(Test.java:33)



Admin is it possible to move my question to java Networking category. Is there any option to move it.
 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think the problem is different, since after couple of mins same code work fine.

This problem might be related to OS as it may hold the previous created connection without timeout and provided the same one to this new code again. So if you get this problem check with netstat in linux...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!