I have been using URL and URLConnetion api's, but getting problem saying,
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.MaiYUYTY.main(Maina.java:34)
You can't connect to the port on the host you specified, and after a timeout it simply fails. Are you sure you can reach the URL? You can try with a regular browser like Internet Explorer or Firefox.
Rob Prime wrote:You can't connect to the port on the host you specified, and after a timeout it simply fails. Are you sure you can reach the URL? You can try with a regular browser like Internet Explorer or Firefox.
Thruogh the browser I can get the page but with code I even not get connected to that URL.
Please let me know if you need any more information.
Thanks
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35247
7
posted
0
Is the browser possibly configured to go through a proxy?
That link is obviously a bit older, since it is missing one option introduced in Java 5.0: use java.net.Proxy. URL has overloaded the openConnection method to take a Proxy object as well.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.