调用[asyncError()]对于具有异步状态[MUST_DISPATCH]的请求无效

时间:2018-12-04 03:17:27

标签: spring-boot spring-boot-admin

env:
案例1
客户端:springboot(1.5.12.RELEASE)+ spring-boot-admin-starter-client 1.5.7

admin:springboot(2.1.1.RELEASE)+ spring-boot-admin-starter-server 2.1.1

当我运行客户端并刷新管理应用程序时。错误是“对于异步状态为[MUST_DISPATCH]的请求,调用[asyncError()]无效”;

案例2
(2.1.1。发布) 客户端和服务器使用相同的版本,并且具有相同的错误。

详细错误如下:

2018-12-04 11:10:40.129 ERROR 2572 --- [nio-9090-exec-5] o.a.catalina.connector.CoyoteAdapter     : Exception while processing an asynchronous request

java.lang.IllegalStateException: Calling [asyncError()] is not valid for a request with Async state [MUST_DISPATCH]
    at org.apache.coyote.AsyncStateMachine.asyncError(AsyncStateMachine.java:440) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:512) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.Request.action(Request.java:430) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.catalina.core.AsyncContextImpl.setErrorState(AsyncContextImpl.java:382) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:239) ~[tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.AbstractProcessor.dispatch(AbstractProcessor.java:241) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_162]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_162]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.13.jar:9.0.13]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_162]

3 个答案:

答案 0 :(得分:0)

SBA-UI正在使用一些长时间轮询,当浏览器关闭连接并且服务器尝试在其上写入一些数据时,会记录上述异常。所有这些都是很正常的。它不应该影响应用程序。 有关更多信息,请访问:https://github.com/spring-projects/spring-boot/issues/15057

答案 1 :(得分:0)

实际上有一个简单的解决方案:只是不要使用Tomcat servlet容器,而是在反应式设置中运行管理服务器,例如:

@SpringBootApplication
@EnableAdminServer
public class AdminServer {
    public static void main(String[] args) {
        new SpringApplicationBuilder(AdminServer.class)
        .web(WebApplicationType.REACTIVE)
        .run(args);
    }
}

这样,我不会出现任何错误。

答案 2 :(得分:0)

尝试开启JETTY,对我有帮助。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <groupId>org.springframework.boot</groupId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>