java.net.No Route To Host Exception: Operation timed out:
Sachin
Greenhorn
Joined: Jan 09, 2002
Posts: 2
posted
0
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
posted
0
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
posted
0
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
posted
0
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
posted
0
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
subject: java.net.No Route To Host Exception: Operation timed out: