gpt4 book ai didi

java - InterruptedIOException 使用 httpClient 4.3.3 for Android

转载 作者:行者123 更新时间:2023-11-30 02:50:11 26 4
gpt4 key购买 nike

我目前有一个高吞吐量的应用程序,我正在使用 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

除了这个随机的小问题外,一切正常。它是随机发生的,所有其他调用似乎都在继续,就好像什么也没发生一样

最佳答案

根据本文档

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

InterruptedIOException

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

关于java - InterruptedIOException 使用 httpClient 4.3.3 for Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24338470/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com