recvfrom failed: ETIMEDOUT (Connection timed out)
1973 ワード
WIFIネットワークとモバイルネットワークが同時に開く、ダウンロード中にWIFIネットワークを閉じる、この時システムがWIFIネットワークを閉じると同時にモバイルネットワークに切り替わる、この過程で、以下の異常が発生し、異常が発生する文はisである.read(buffer)、コードセグメントは次のとおりです.
Catch IO exception when read data from input stream.
java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out)
at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:542)
at libcore.io.IoBridge.recvfrom(IoBridge.java:506)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
at libcore.net.http.FixedLengthInputStream.read(FixedLengthInputStream.java:45)
at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
at java.io.InputStream.read(InputStream.java:163)
at com.tvie.ivideo.download.logic.DownThread.run(DownThread.java:70)
Caused by: libcore.io.ErrnoException: recvfrom failed: ETIMEDOUT (Connection timed out)
at libcore.io.Posix.recvfromBytes(Native Method)
at libcore.io.Posix.recvfrom(Posix.java:131)
at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
at libcore.io.IoBridge.recvfrom(IoBridge.java:503)
... 8 more
転載先:https://blog.51cto.com/truesea/1344336
try{
while ((len = is.read(buffer)) != -1) {
if(!CommonUtils.isDownloadAvailable()) {
Logger.v(TAG, "Download operation is unavailable, stop down.");
break;
}
if(!running) {
Logger.v(TAG, "Down is cancelled, stop down.");
break;
}
offset += len;
file.write(buffer, 0, len);
sendMessage(DownMessage.MSG_UPDATE, len);
}
}catch(IOException e) {
Logger.e(TAG, "Catch IO exception when read data from input stream.", e);
throw e;
}
Catch IO exception when read data from input stream.
java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out)
at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:542)
at libcore.io.IoBridge.recvfrom(IoBridge.java:506)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
at libcore.net.http.FixedLengthInputStream.read(FixedLengthInputStream.java:45)
at java.io.BufferedInputStream.read(BufferedInputStream.java:304)
at java.io.InputStream.read(InputStream.java:163)
at com.tvie.ivideo.download.logic.DownThread.run(DownThread.java:70)
Caused by: libcore.io.ErrnoException: recvfrom failed: ETIMEDOUT (Connection timed out)
at libcore.io.Posix.recvfromBytes(Native Method)
at libcore.io.Posix.recvfrom(Posix.java:131)
at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
at libcore.io.IoBridge.recvfrom(IoBridge.java:503)
... 8 more
転載先:https://blog.51cto.com/truesea/1344336