IntelliJ Java IDE
The moose likes Sockets and Internet Protocols and the fly likes java.net.No Route To Host Exception: Operation timed out: Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "java.net.No Route To Host Exception: Operation timed out:" Watch "java.net.No Route To Host Exception: Operation timed out:" New topic
Author

java.net.No Route To Host Exception: Operation timed out:

Sachin
Greenhorn

Joined: Jan 09, 2002
Posts: 2
I get the above exception when I try to access the http url through my application.
Heres my chunk of code:
System.setProperty("ProxySet","true");
System.setProperty("ProxyHost","proxy.dlwc.nsw.gov.au");
System.setProperty("ProxyPort","8080");
String url="http://ids.lpi.nsw.gov.au/ipw/ipw-xml-link.php";
URL target=new URL(url);
conn = (HttpURLConnection)target.openConnection();
System.out.println("Response message = " + conn.getResponseMessage());
conn.setRequestMethod("POST");
conn.setAllowUserInteraction(true);
conn.setRequestProperty("content-type","text/xml");
conn.setDoInput(true);
conn.setDoOutput(true);
System.out.println(conn);
conn.connect();
And Heres the stack of error:

java.net.NoRouteToHostException: Operation timed out: no further information
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:312)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:125)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:112)
at java.net.Socket.<init>(Socket.java:273)
at java.net.Socket.<init>(Socket.java:100)
at sun.net.NetworkClient.doConnect(NetworkClient.java:50)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:331)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:517)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:277)
at sun.net.www.http.HttpClient.New(HttpClient.java:289)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:379)
at query.IPWLotQuery.getItems(IPWLotQuery.java:103)
at query.IPWLotQuery.doPost(IPWLotQuery.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)

Any help appreciated.
Laudney Ren
Ranch Hand

Joined: Jan 06, 2002
Posts: 111
try to put conn.connect(); just after conn = (HttpURLConnection)target.openConnection();


" Veni, vidi, vici "<br />" I came, I saw, I conquered "
Sachin
Greenhorn

Joined: Jan 09, 2002
Posts: 2
Thanks for the reply but it doesnt help as i put debug message right after the openConnection() command and it doesnt reach upto that.
Thanks anyway
Sachin
ping203
Greenhorn

Joined: Jan 10, 2002
Posts: 5
From the API,
NoRouteToHostException - Signals that an error occurred while attempting to connect a socket to a remote address and port. Typically, the remote host cannot be reached because of an intervening firewall, or if an intermediate router is down.
So, I guess when you call openConnection, it fails to reach the url you specified.
you can try to connect to that url by other means, like a browser, to see if you can connect to it or not.
Ping
ersin eser
Ranch Hand

Joined: Feb 22, 2001
Posts: 1072
Sachin and ping203,
welcome to JRanch and we hope to see you here again but would you kindly read our naming policy and reregister with a proper name?
www.javaranch.com/name.jsp
 
jQuery in Action, 2nd edition
 
subject: java.net.No Route To Host Exception: Operation timed out:
 
Threads others viewed
java.net.ConnectException: Connection timed out:check service is available or not
SocketException in WSAD
java Scanner
WSAD Stock Quote Web service tutorial: Proxy problem
I tried to send an xml to an url its ,
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture