Open zengjingfang opened 6 years ago
java.net.SocketException: Software caused connection abort
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:114)
at java.net.SocketInputStream.read(SocketInputStream.java:170)
at java.net.SocketInputStream.read(SocketInputStream.java:139)
at java.net.SocketInputStream.read(SocketInputStream.java:125)
java.net.SocketException: Socket closed
at libcore.io.Posix.recvfromBytes(Native Method)
at libcore.io.Posix.recvfrom(Posix.java:185)
at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
at libcore.io.IoBridge.recvfrom(IoBridge.java:553)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485)
at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
at java.io.InputStream.read(InputStream.java:162)
华为手机连一个手机打开的热点WiFi正在下载,此时关闭发热点的数据流量,这样就连接一个无效的WiFi。问题是自己的代码无法捕获系统的异常,这个系统的异常打印。猜测是系统层捕获了没有往上抛出。
01-16 17:31:22.652 3477-17850/? E/SUPL20_NC: Error on Connection 74.125.31.192:7276 NI:13 CC:1
01-16 17:31:22.662 3477-17850/? E/SUPL20_NC: failed to connect to /74.125.31.192 (port 7276) after 10000ms
java.net.SocketTimeoutException: failed to connect to /74.125.31.192 (port 7276) after 10000ms
at libcore.io.IoBridge.connectErrno(IoBridge.java:189)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:898)
at com.android.supl.nc.NetworkController.getSocket(NetworkController.java:379)
at com.android.supl.nc.NetworkController.connect(NetworkController.java:483)
at com.android.supl.commprocessor.NetworkCommandProcessor$1.run(NetworkCommandProcessor.java:271)
01-16 17:31:22.662 3477-17850/? E/SUPL20_NetCP: Session id :0 Req id :0 is not connected to 74.125.31.192
``
关闭网络
java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out)
at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:595)
at libcore.io.IoBridge.recvfrom(IoBridge.java:559)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:481)
at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
at java.io.InputStream.read(InputStream.java:162)
java.net.UnknownHostException: Host is unresolved: xxxx
Reason :Usually the UnknownHostException fires when you cannot resolve the DNS record of the URL you've provided. There's a reasonable timeout for that operation, but if you have a weak Wi-Fi connection or you don't have enough signal on your device, the communication can be interrupted in the middle between sending and receiving the response, so your device doesn't receive the response, thus it thinks it's a DNS timeout.
There are two means reasons
If your wifi signals week If your your device connected to the wifi but no internet availability.
https://stackoverflow.com/questions/37314712/how-to-resolve-java-net-unknownhostexception
1、 java.net.SocketException: sendto failed: EBADF (Bad file descriptor)