Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Sachin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try to put conn.connect(); just after conn = (HttpURLConnection)target.openConnection();
 
Sachin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1072
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!