Java.net.ConnectException

When I launch my application via Google Nexus, connecting via USB and trying to connect to the webservice running on my laptop, I get below error, but I can connect to webservie. Please advice.

java.net.ConnectException: failed to connect to /192.168.1.122 (port 8080): connect failed: ENETUNREACH (Network is unreachable) at libcore.io.IoBridge.connect(IoBridge.java:114) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.Socket.startupSocket(Socket.java:566) at java.net.Socket.tryAllAddresses(Socket.java:127) at java.net.Socket.<init>(Socket.java:177) at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80) at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122) at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) 
+4
source share
2 answers

Just because you connect your phone to a computer does not mean that it will create a network connection.

Create a LAN by running the web service on the LAN server. and use wifi to connect to it.

+2
source

You need to publish the services in the place where your phone can connect to them through Wireless Lan. USB is for debugging purposes only

0
source

All Articles