aspose file tools*
The moose likes Java in General and the fly likes HttpURLConnection.connect() times out, while wget works fine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HttpURLConnection.connect() times out, while wget works fine" Watch "HttpURLConnection.connect() times out, while wget works fine" New topic
Author

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

Ruben Matthews
Greenhorn

Joined: Jan 05, 2009
Posts: 26
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

Joined: Jan 05, 2009
Posts: 26
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

Joined: Oct 13, 2005
Posts: 38398
    
  23
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

Joined: Oct 27, 2005
Posts: 19672
    
  18

It's a good thing URL has an openConnection(Proxy) method


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: HttpURLConnection.connect() times out, while wget works fine