【发布时间】:2014-06-21 05:03:46
【问题描述】:
我目前有一个具有高吞吐量的应用程序,我正在使用 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
除了这个随机的打嗝之外,一切都很好。它是随机发生的,所有其他调用似乎都在继续,好像什么都没发生一样
【问题讨论】:
-
线程现在我确实有一个线程可以清理过期和超时连接我必须清除关闭正在执行网络操作的线程
-
我实现这个线程的原因最初是为了解决这个问题。我以为连接管理器正在泄漏连接,但我错了。即使没有它,我也会看到这个问题。
标签: java android httpclient androidhttpclient