java.net.SocketException:recvfrom 失败:ETIMEDOUT(连接超时)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16912132/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out)
提问by SAR
I am making HTTP requests too frequently and after some time getting this Exception:
我发出 HTTP 请求过于频繁,一段时间后出现此异常:
java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out)
java.net.SocketException:recvfrom 失败:ETIMEDOUT(连接超时)
I have gone through all of this related post.
我已经浏览了所有这些相关的帖子。
But I don't get how to solve this. They have mentioned to clear the DNS cache, but I need to clear it in runtime, so that my execution does not stop working, which is not possible in Android.
但我不明白如何解决这个问题。他们提到清除DNS缓存,但我需要在运行时清除它,以便我的执行不会停止工作,这在Android中是不可能的。
Can anybody tell me the solution.
谁能告诉我解决办法。
Here is my log:
这是我的日志:
06-04 11:14:08.119: W/System.err(8338): java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out) 06-04 11:14:08.139: W/System.err(8338): at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:552) 06-04 11:14:08.139: W/System.err(8338): at libcore.io.IoBridge.recvfrom(IoBridge.java:516) 06-04 11:14:08.139: W/System.err(8338): at java.net.PlainSocketImpl.read(PlainSocketImpl.java:489) 06-04 11:14:08.139: W/System.err(8338): at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46) 06-04 11:14:08.139: W/System.err(8338): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:241) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:191) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:82) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:180) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.AbstractHttpClient$1.executeRequestSending(AbstractHttpClient.java:608) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.naf.redirect.NafRequestExecutorWrapperRedirectionHandler.executeRequestSendingUsual(NafRequestExecutorWrapperRedirectionHandler.java:96) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.naf.redirect.NafRequestExecutorWrapperRedirectionHandler.executeRequestSending(NafRequestExecutorWrapperRedirectionHandler.java:73) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.naf.auth.NafHttpAuthStrategyDefault.sendFirstRequest(NafHttpAuthStrategyDefault.java:488) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.naf.auth.NafHttpAuthStrategyDefault.performAuthExecutionUnsafe(NafHttpAuthStrategyDefault.java:389) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.naf.auth.NafHttpAuthStrategyDefault.performAuthExecution(NafHttpAuthStrategyDefault.java:200) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
06-04 11:14:08.119: W/System.err(8338): java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out) 06-04 11:14:08.139: W/System.err(8338) : 在 libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:552) 06-04 11:14:08.139: W/System.err(8338): 在 libcore.io.IoBridge.recvfrom(IoBridge.java:516) 06 -04 11:14:08.139: W/System.err(8338): 在 java.net.PlainSocketImpl.read(PlainSocketImpl.java:489) 06-04 11:14:08.139: W/System.err(8338):在 java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46) 06-04 11:14:08.139: W/System.err(8338): 在 java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:241 ) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103) 06-04 11:14:08.139: W /系统。err(8338): 在 org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:191) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http .impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:82) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser. java:174) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:180) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235) 06-04 11:14:08.139: W/System.err(8338): at org .apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279) 06-04 11:14:08.139: W/ System.err(8338): 在 org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http .impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http.impl.client.AbstractHttpClient$1.executeRequestSending(AbstractHttpClient) .java:608) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http.impl.client.naf.redirect.NafRequestExecutorWrapperRedirectionHandler.executeRequestSendingUsual(NafRequestExecutorWrapper96RedirectionHandler.java: 04 11:14:08.139:W/System.err(8338):在 org.apache.http.impl.client。naf.redirect.NafRequestExecutorWrapperRedirectionHandler.executeRequestSending(NafRequestExecutorWrapperRedirectionHandler.java:73) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http.impl.client.naf.AuthStrategyDefault.Nafend (NafHttpAuthStrategyDefault.java:488) 06-04 11:14:08.139: W/System.err(8338): 在 org.apache.http.impl.client.naf.auth.NafHttpAuthStrategyDefault.performAuthExecutionUnsafe(NafHttpAuthStrategyDefault.java:389) 06-04 11:14:08.139:W/System.err(8338):在 org.apache.http.impl.client.naf.auth.NafHttpAuthStrategyDefault.performAuthExecution(NafHttpAuthStrategyDefault.java:200) 06-04 11:14: 08.139: W/System.err(8338): 在 org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:557) 06-04 11:14:08.139: W/System.err(8338):在 org.apache.http.impl.client。AbstractHttpClient.execute(AbstractHttpClient.java:509) 06-04 11:14:08.139: W/System.err(8338): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
回答by user207421
See http://www.mail-archive.com/[email protected]/msg23588.html: "You can get this if the TCP connection times out, either through a keepalive timeout or the protocol hits the maximum number of transmit retries." It doesn't have anything to do with DNS.
请参阅http://www.mail-archive.com/[email protected]/msg23588.html:“如果 TCP 连接超时,您可以通过 keepalive 超时或协议达到最大数量传输重试。” 它与 DNS 没有任何关系。