java.net.SocketException:recvfrom失败:ETIMEDOUT(连接超时)

时间:2013-06-04 07:29:38

标签: java android

我过于频繁地发出HTTP请求,并在一段时间后得到此异常:

  

java.net.SocketException:recvfrom失败:ETIMEDOUT(连接超时)

我已经完成了所有这些related post

但我不知道如何解决这个问题。他们提到要清除DNS缓存,但我需要在运行时清除它,这样我的执行就不会停止工作,这在Android中是不可能的。

任何人都可以告诉我解决方案。

这是我的日志:

  

06-04 11:14:08.119:W / System.err(8338):java.net.SocketException:   recvfrom失败:ETIMEDOUT(连接超时)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)

1 个答案:

答案 0 :(得分:-2)

请参阅http://www.mail-archive.com/freebsd-hackers@freebsd.org/msg23588.html:“如果TCP连接超时,可以通过keepalive超时或协议达到最大传输重试次数来获取此信息。”它与DNS没有任何关系。