尝试从Android应用程序连接时,拒绝连接到IP

时间:2016-10-07 10:25:46

标签: android httpconnection

我正在尝试将我的Android应用程序与运行在同一台PC上的服务器连接,ip为192.168.1.129,而tomcat端口为8081,低于问题,任何人都可以帮我解决这个问题吗?

10-07 15:51:45.672 29710-5937/com.net.app W/System.err: org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.129:8081 refused
10-07 15:51:45.673 29710-5937/com.net.app W/System.err:     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:188)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err:     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:169)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err:     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:124)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err:     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:379)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:580)
10-07 15:51:45.673 29710-5937/com.net.app W/System.err:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:503)
10-07 15:51:45.674 29710-5937/com.net.app W/System.err:     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:481)
10-07 15:51:45.679 29710-5937/com.net.app W/System.err:     at com.chronicwatch.app.utils.WebRequest.post(WebRequest.java:72)
10-07 15:51:45.679 29710-5937/com.net.app W/System.err:     at com.chronicwatch.app.utils.WebRequest.loadDataFromNetwork(WebRequest.java:54)
10-07 15:51:45.679 29710-5937/com.net.app W/System.err:     at com.octo.android.robospice.request.CachedSpiceRequest.loadDataFromNetwork(CachedSpiceRequest.java:48)
10-07 15:51:45.680 29710-5937/com.net.app  W/System.err:     at com.octo.android.robospice.request.DefaultRequestRunner.processRequest(DefaultRequestRunner.java:150)
10-07 15:51:45.680 29710-5937/com.net.app W/System.err:     at com.octo.android.robospice.request.DefaultRequestRunner$1.run(DefaultRequestRunner.java:217)
10-07 15:51:45.680 29710-5937/com.net.app W/System.err:     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
10-07 15:51:45.680 29710-5937/com.net.app W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
10-07 15:51:45.681 29710-5937/com.net.app W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-07 15:51:45.681 29710-5937/com.net.app W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-07 15:51:45.681 29710-5937/com.net.app W/System.err:     at java.lang.Thread.run(Thread.java:818)
10-07 15:51:45.681 29710-5937/com.net.app W/System.err: Caused by: java.net.ConnectException: failed to connect to /192.168.1.129 (port 8081) after 15000ms: isConnected failed: EHOSTUNREACH (No route to host)
10-07 15:51:45.682 29710-5937/com.net.app W/System.err:     at libcore.io.IoBridge.isConnected(IoBridge.java:238)
10-07 15:51:45.682 29710-5937/com.net.app W/System.err:     at libcore.io.IoBridge.connectErrno(IoBridge.java:171)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err:     at libcore.io.IoBridge.connect(IoBridge.java:122)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err:     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err:     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:456)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err:     at java.net.Socket.connect(Socket.java:882)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err:     at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:124)
10-07 15:51:45.683 29710-5937/com.net.app W/System.err:     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:149)
10-07 15:51:45.685 29710-5937/com.net.app W/System.err:     ... 16 more
10-07 15:51:45.685 29710-5937/com.net.app W/System.err: Caused by: android.system.ErrnoException: isConnected failed: EHOSTUNREACH (No route to host)
10-07 15:51:45.686 29710-5937/com.net.app W/System.err:     at libcore.io.IoBridge.isConnected(IoBridge.java:223)
10-07 15:51:45.686 29710-5937/com.net.app W/System.err:     ... 23 more

2 个答案:

答案 0 :(得分:0)

可能有两个问题。首先,防火墙可以阻止访问。关闭它进行测试。第二:也许Tomcat仅限于localhost / 127.0.0.1。检查其设置。

答案 1 :(得分:0)

修正了,我的PC的公共IP不同,Android手机的公共IP不同(连接到另一个Wi-Fi),但两者应该相同