wood burning stoves*
The moose likes Sockets and Internet Protocols and the fly likes HttpURLConnection timed out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "HttpURLConnection timed out" Watch "HttpURLConnection timed out" New topic
Author

HttpURLConnection timed out

San-Yih Pan
Greenhorn

Joined: Nov 04, 2004
Posts: 19
Hi,

Anyboby can help point out what wrong with "Connection timed out from HttpURLConnection to some URL". The laptop XP and Unix machine have the same issues. Please see the error messages as below.
For comparison, that Http request got connection by POST command lines.
I am wondering the problem is from configuration or Http proxy (XP???).

Thanks in advance
San-Yih
--------------------------------------------------------------------
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:315)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:521)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:498)
at com.att.wimax.netspan.HttpSender.post(HttpSender.java:58)
at com.att.wimax.netspan.HttpSender.sendHttp(HttpSender.java:31)
at com.att.wimax.netspan.STServiceImpl.main(STServiceImpl.java:44)

The return message ...
Time elapsed: 21063ms
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
This could be a firewall issue. Firewalls are often configured to discard packets. Discarded packets would cause a connection timeout after several seconds (as opposed to a rejected packet that would give you an immediate connection failure).

Here are a few things to check:

Can you telnet from the laptop or Unix server to port 80 (or whatever port you are connecting to) on the HTTP server?

Are you using a proxy? Are the settings correct?

Can a browser on the client computer connect to the HTTP server?

Can you get to other web sites from the client?
San-Yih Pan
Greenhorn

Joined: Nov 04, 2004
Posts: 19
Hi scott,

I am not using proxy. The client browser can access the other web sides.

I did some simple tests as follows:
(1) http://IPAddress/../../Login.aspx working from client browser and it is working for POST command line.
(2) http://IPAddress:80 shows "The Web is under construction".
(3) Telnet from DOS. "telnet IPAddress 80" then type "Get <Enter>" shows
"Http/1.1 400 Bad Request
Content-type: text/html
Date: Mon, 14 Nov 2005 13:15:56 GMT
Connection: close
Content-Length: 35

<h1>Bad Request(invalid verb)</h1>
Connection to host lost."

Thanks,
San-Yih
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
I assume you did these tests on the actual computer running the Java program having trouble.

I would make sure you are connecting to the correct server/IP address and port in the program. (Print some debug messages.)

Then I would use a network analyzer like Ethereal to monitor what packets the program is sending and the response (of lack thereof) it's receiving. Verify the IP address and port are what you think they should be.
[ November 14, 2005: Message edited by: Scott Johnson ]
San-Yih Pan
Greenhorn

Joined: Nov 04, 2004
Posts: 19
Hi Scott,

Do you want me to download network analyzer and capture the information?

One coworker is testing with me at the same machine with different account. He is fine. We logined through SECure CRT to Unix, the same .profile, the same Java version.
I changed to login through Hummingbird. Sometimes got some progress.

Thanks,
San-Yih
San-Yih Pan
Greenhorn

Joined: Nov 04, 2004
Posts: 19
Hi Scott,

We found one mistake on our side and fixed. It is working now.
Thank you for your help.

San-Yih
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HttpURLConnection timed out