使用httpClient 4.3.3 for Android的InterruptedIOException

时间:2014-06-21 05:03:47

标签: java android httpclient androidhttpclient

我目前有一个具有高吞吐量的应用程序,我正在使用Apache自己提供的httpClient 4.3.3。我有一个问题,我在一段时间后不断收到InterruptedIOException。原因是ConnectionShutdownException。我想知道是否有人知道为什么会发生这种情况。

我已经发现错误是在CPoolProxy行135中抛出的。看起来getConnection()调用失败了,因为用于创建CPoolEntry的poolEntry为空。

现在我有一个线程可以清除过期和超时连接,并为连接/套接字设置超时。我现在不知所措。这是堆栈跟踪:

06-20 21:45:01.424: W/System.err(22978): java.io.InterruptedIOException: Connection has been shut down
06-20 21:45:01.424: W/System.err(22978):    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:337)
06-20 21:45:01.424: W/System.err(22978):    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
06-20 21:45:01.424: W/System.err(22978):    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
06-20 21:45:01.424: W/System.err(22978):    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
06-20 21:45:01.424: W/System.err(22978):    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
06-20 21:45:01.424: W/System.err(22978):    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
06-20 21:45:01.424: W/System.err(22978):    at com.loopj.android.http.core.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:98)
06-20 21:45:01.434: W/System.err(22978):    at com.loopj.android.http.core.AsyncHttpRequest.run(AsyncHttpRequest.java:68)
06-20 21:45:01.434: W/System.err(22978):    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
06-20 21:45:01.434: W/System.err(22978):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-20 21:45:01.434: W/System.err(22978):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-20 21:45:01.434: W/System.err(22978):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-20 21:45:01.434: W/System.err(22978):    at java.lang.Thread.run(Thread.java:841)
06-20 21:45:01.434: W/System.err(22978): Caused by: org.apache.http.impl.conn.ConnectionShutdownException
06-20 21:45:01.444: W/System.err(22978):    at org.apache.http.impl.conn.CPoolProxy.invoke(CPoolProxy.java:135)
06-20 21:45:01.444: W/System.err(22978):    at $Proxy0.getSSLSession(Native Method)
06-20 21:45:01.444: W/System.err(22978):    at org.apache.http.impl.client.DefaultUserTokenHandlerHC4.getUserToken(DefaultUserTokenHandlerHC4.java:80)
06-20 21:45:01.444: W/System.err(22978):    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:320)
06-20 21:45:01.444: W/System.err(22978):    ... 12 more

除了这种随机打嗝外,一切运作良好。它随机发生,所有其他调用似乎继续,好像没有任何反应

1 个答案:

答案 0 :(得分:1)

按照本文件

http://docs.oracle.com/javase/7/docs/api/java/io/InterruptedIOException.html

<强> InterruptedIOException

表示I / O操作已中断。抛出InterruptedIOException是为了表示输入或输出传输已被终止,因为执行它的线程被中断。字段bytesTransferred表示在中断发生之前成功传输了多少字节。