安卓 java.net.SocketTimeoutException: failed to connect to 异常

安卓访问自己本地搭载的服务后,提示java.net.SocketTimeoutException: failed to connect to /172.16.31.94 (port 8089) from /10.132.183.38 (port 53582) after 8000ms 异常 如下:
06-02 14:36:20.958 7815-8163/com.example.caliv.ffyy W/System.err: java.net.SocketTimeoutException: failed to connect to /172.16.31.94 (port 8089) from /10.132.183.38 (port 53582) after 8000ms
06-02 14:36:20.959 7815-8163/com.example.caliv.ffyy W/System.err: at libcore.io.IoBridge.connectErrno(IoBridge.java:191)
06-02 14:36:20.959 7815-8163/com.example.caliv.ffyy W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:135)
06-02 14:36:20.959 7815-8163/com.example.caliv.ffyy W/System.err: at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
06-02 14:36:20.959 7815-8163/com.example.caliv.ffyy W/System.err: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
06-02 14:36:20.959 7815-8163/com.example.caliv.ffyy W/System.err: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
06-02 14:36:20.959 7815-8163/com.example.caliv.ffyy W/System.err: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
06-02 14:36:20.959 7815-8163/com.example.caliv.ffyy W/System.err: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
06-02 14:36:20.959 7815-8163/com.example.caliv.ffyy W/System.err: at java.net.Socket.connect(Socket.java:621)
06-02 14:36:20.959 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.Platform.connectSocket(Platform.java:182)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:145)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
06-02 14:36:20.960 7815-8163/com.example.caliv.ffyy W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:262)
06-02 14:36:20.961 7815-8163/com.example.caliv.ffyy W/System.err: at com.example.caliv.ffyy.ConnHt.sendHttp(ConnHt.java:28)
06-02 14:36:20.961 7815-8163/com.example.caliv.ffyy W/System.err: at com.example.caliv.ffyy.Tj_ffyy_grsjtjActivity$5.run(Tj_ffyy_grsjtjActivity.java:220)
06-02 14:36:20.961 7815-8163/com.example.caliv.ffyy W/System.err: at java.lang.Thread.run(Thread.java:929)

解决方法:
让电脑和手机处于同一个局域网即可,电脑与手机连接同一Wifi,关掉流量。

你可能感兴趣的:(代码,安卓,android)