Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpURLConnection.connect() times out, while wget works fine

 
Ruben Matthews
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Java friends

I have a problem where an application I am working on is throwing the following exception "java.net.ConnectException: Connection timed out" after trying to connect() to a URI.



This small test case outputs

YEEEEHAAAAH
test1

and then stalls....



I tried to "wget" the url from the box the application is running on and that works fine. It returns 200 OK. So, the url is accessible, but still connect() times out.

Any clue why?
 
Ruben Matthews
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just talked to our network admin and he explained to me it is caused by the fact that the application (tomcat) is not going through the proxy. Problem is solved.
 
Campbell Ritchie
Sheriff
Posts: 48645
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done solving it, and thank you for giving a solution; it will be helpful if anybody else has a similar problem ever.
 
Rob Spoor
Sheriff
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a good thing URL has an openConnection(Proxy) method
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic