CodeGuru Forums > Java Programming > Java Programming > HttpURLConnection: java.net.ConnectException: Connection timed out:
Click to See Complete Forum and Search --> : HttpURLConnection: java.net.ConnectException: Connection timed out:
vadirajak1
January 11th, 2005, 03:44 AM
Hi,
I am trying to read from a URL and display the contents in an Applet. I am using URL,HttpURLConnection classes. I am consistently getting Connection time out Exception. I am unable to connect. Could any one help me out with this. I have tried some TimeOut handler classes available on the net but still I am getting the same Exception. Please provide your comments if you have come across similar problems before.
Here is the code Iam using
url = new URL((URL)null, str, new HttpTimeoutHandler(15000)); // timeout value in milliseconds
HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
httpConnection.connect();
nputStream is = httpConnection.getInputStream();
Thanks & Regards,
Vadi
cma
January 11th, 2005, 07:57 AM
Can you connect to the server directly, say, using your browser?
cjard
January 11th, 2005, 08:53 AM
connection timeouts occur when:
the IP address for the requested server is successfully found
connection establishment packets are dispatched to the IP address
the destination address deliberately ignores or does not receive them
similar to connection timeout is Connection Refused, but in this case the destination system is actually sending packets back saying "go away, there is no service running on the port you are trying to connect to"
your packets are just being lost.. either the system or some intermediate system is firewalled. follow CMA's advice.. if you cant connect using telnet, a browser or some other app, its a network problem, not a java one
vadirajak1
January 12th, 2005, 01:11 AM
I am able to connect to the url through browser and able to see the data that is there. But when trying to connect through the code, I am getting the connection time out exception. So this must not be a Network/Firewall related issue. Also, the same code is working fine when we tried testing it from the US, but it is giving the timeout Exception when tried from India. Is this a simple time out issue? If so, even some of the time out handlers available on the net are not solving the issue? Can anyone suggest a way out please.
Thanks & Regards,
Vadi
cjard
January 12th, 2005, 07:52 AM
check your browser proxy settings
try using telnet to connect to the same server that youre using in code and the browser:
telnet www.google.com 80
codeguru.com
Copyright 2009 WebMediaBrands Inc., All Rights Reserved.