当我通过谷歌Nexus运行我的应用程序时,通过USB连接并尝试连接在我的笔记本电脑上运行的webservice,然后我收到以下错误但我能够连接到webservie。请指教。
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)
答案 0 :(得分:2)
仅仅因为您将手机连接到计算机并不意味着它会创建网络连接。
创建LAN在LAN IP上运行Web服务。并使用wifi连接到它。
答案 1 :(得分:0)
您需要将服务发布到手机可通过无线局域网连接的位置。 USB仅用于调试目的