java.lang.IllegalStateException: 请求无法执行;I/O 反应器状态:STOPPED

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35350376/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 00:02:22  来源:igfitidea点击:

java.lang.IllegalStateException: Request cannot be executed; I/O reactor status: STOPPED

javahttpapache-httpcomponentsapache-httpasyncclient

提问by knash

I have a service that is expected to execute requests at ~5 or more requests/min. This service depends on Apache AsyncHttpClient. After every few minutes, the clients hits some condition which causes java.lang.IllegalStateException: Request cannot be executed; I/O reactor status: STOPPED. All requests to the client start failing with same exception message. After service is restarted, this cycle repeats.

我有一项服务,预计以 ~5 个或更多请求/分钟的速度执行请求。该服务依赖于 Apache AsyncHttpClient。每隔几分钟,客户端就会遇到一些导致java.lang.IllegalStateException: 请求无法执行的条件;I/O 反应器状态: STOPPED。对客户端的所有请求都以相同的异常消息开始失败。服务重新启动后,重复此循环。

It is really hard to debug this problem as the request execution failure surprisingly does not cause a callback to the failed()method of the AsyncResponse.

这个问题真的很难调试,因为请求执行失败出人意料地不会导致对 AsyncResponse的failed()方法的回调。

From what I could gather, there has been a fix HTTPCORE-370in HttpCore NIOwhich solved a similar problem in 4.3.2. I am using the following version -

据我所知,在HttpCore NIO 中已经修复了HTTPCORE-370,它解决了 4.3.2 中的类似问题。我正在使用以下版本 -

commons-httpclient-3.1.jar
httpasyncclient-4.1.1.jar
httpcore-4.4.4.jar
httpcore-nio-4.4.4.jar

commons-httpclient-3.1.jar
httpasyncclient-4.1.1.jar
httpcore-4.4.4.jar
httpcore-nio-4.4.4.jar

Yet seeing this problem.

还是看到这个问题。

回答by Madpony

I've been dealing with this same exception in my application, and I finally found a helpful suggestion from this post - http://httpcomponents.10934.n7.nabble.com/I-O-reactor-status-STOPPED-td29059.html

我一直在我的应用程序中处理同样的异常,我终于从这篇文章中找到了一个有用的建议 - http://httpcomponents.10934.n7.nabble.com/IO-reactor-status-STOPPED-td29059.html

You can use #getAuditLog() method of the I/O reactor to find out exactly what exception caused it to terminate.

您可以使用 I/O 反应器的 #getAuditLog() 方法来准确找出导致它终止的异常。

If you keep a reference to your ConnectionManager's IOReactor, you can call this method to get insight into the actual problem:

如果您保留对 ConnectionManager 的 IOReactor 的引用,则可以调用此方法以深入了解实际问题:

http://hc.apache.org/httpcomponents-core-4.4.x/httpcore-nio/apidocs/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.html#getAuditLog()

http://hc.apache.org/httpcomponents-core-4.4.x/httpcore-nio/apidocs/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.html#getAuditLog()

Turns out I was doing something incredibly stupid in my own code. But I couldn't figure it out until I read the audit log.

原来我在自己的代码中做了一些非常愚蠢的事情。但是直到我阅读了审计日志我才弄明白。

回答by Kalpesh Soni

If you see OutOfMemoryError before this, try this

如果您在此之前看到 OutOfMemoryError,请尝试此操作

-XX:MaxDirectMemorySize=512M

-XX:MaxDirectMemorySize=512M

See https://issues.apache.org/jira/browse/HTTPASYNC-104

https://issues.apache.org/jira/browse/HTTPASYNC-104