22

I'm currently running Spring Boot Admin on my local machine for testing purposes and I'm getting the following error nonstop. The application itself seems to be working fine, but my logs are getting filled with these errors. I'm not sure why...

 org.springframework.web.context.request.async.AsyncRequestTimeoutException: null
    at org.springframework.web.context.request.async.TimeoutDeferredResultProcessingInterceptor.handleTimeout(TimeoutDeferredResultProcessingInterceptor.java:42) ~[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.web.context.request.async.DeferredResultInterceptorChain.triggerAfterTimeout(DeferredResultInterceptorChain.java:75) ~[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.web.context.request.async.WebAsyncManager$5.run(WebAsyncManager.java:392) ~[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.web.context.request.async.StandardServletAsyncWebRequest.onTimeout(StandardServletAsyncWebRequest.java:143) ~[spring-web-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.apache.catalina.core.AsyncListenerWrapper.fireOnTimeout(AsyncListenerWrapper.java:44) ~[tomcat-embed-core-8.5.5.jar!/:8.5.5]
    at org.apache.catalina.core.AsyncContextImpl.timeout(AsyncContextImpl.java:131) ~[tomcat-embed-core-8.5.5.jar!/:8.5.5]
    at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:157) ~[tomcat-embed-core-8.5.5.jar!/:8.5.5]
    at org.apache.coyote.AbstractProcessor.dispatch(AbstractProcessor.java:228) [tomcat-embed-core-8.5.5.jar!/:8.5.5]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53) [tomcat-embed-core-8.5.5.jar!/:8.5.5]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802) [tomcat-embed-core-8.5.5.jar!/:8.5.5]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410) [tomcat-embed-core-8.5.5.jar!/:8.5.5]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.5.jar!/:8.5.5]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_40]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_40]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.5.jar!/:8.5.5]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40]
Pinkie Swirl
  • 2,375
  • 1
  • 20
  • 25
Martin
  • 365
  • 1
  • 3
  • 9
  • An issue has been raised on this: https://github.com/codecentric/spring-boot-admin/issues/286. And here the underlying Spring Issue: https://jira.spring.io/browse/SPR-14739 – joshiste Oct 04 '16 at 17:02
  • Thank you for bringing this up. I guess it will get fixed in the next release. – Martin Oct 04 '16 at 17:09

4 Answers4

39

I also had similar error. try this property in you application.yml

spring:
  mvc:
    async:
      request-timeout: -1  
James Monger
  • 10,181
  • 7
  • 62
  • 98
Vinod Yadav
  • 430
  • 4
  • 5
  • 4
    Hi @VinodYadav, welcome to Stack Overflow. I've edited your answer to wrap your code in a code tag so that it's easier to read. – James Monger Oct 12 '16 at 18:36
  • Thanks @Vinod, that worked wonderfully. A repo example illustrate this problem [https://github.com/dilbertside/compose-spring-boot-admin ] remove the property and the AsyncRequestTimeoutException reappears. – dilbertside Nov 07 '16 at 11:20
  • 12
    Beware of making the async timeout to -1, a few of these types of requests will hold on to a thread / socket and may cause starvation of resources if sufficiently large no. of requests are made. – Kamal Joshi Mar 15 '17 at 13:35
  • This is what would be called "Save the day" – lealceldeiro Dec 26 '21 at 09:17
5

Alternatively without spring boot, add

    @Override
    public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
        long timeout = 5 * 60 * 1000;// for example 5 minutes
        WebMvcConfigurer.super.configureAsyncSupport(configurer);
        configurer.setDefaultTimeout(timeout);
    }

to the configuration class that implements WebMvcConfigurer

George Vinokhodov
  • 327
  • 1
  • 4
  • 10
3

Instead of configuring the timeout on application level you can configure the timeout for specific subscription.

    @GetMapping(value = "/subscription")
    public SseEmitter subscription() {
        SseEmitter emitter = new SseEmitter((long) (60000 * 5));
        return emitter;
    }

So in the above excerpt, I gave 5 minutes for this particular connection. Rest of the connections will still use the server default timeout.

  • I am using the sse and facing the similiar problem, fixed it by using your answer, seems this question not using sse. – Dolphin Mar 27 '23 at 17:30
  • Super helpful! and easy to implement in case when we have just couple of async methods. – Learn More Jul 25 '23 at 11:28
3

In case of using ComplatebleFuture<Any> as return type of @RestController function and using Tomcat as backing container.Then is required to register catalina Connector customizer into spring context, which will adjust async connection timeout. Because org.apache.catalina.connector.Connector has its own property protected long asyncTimeout = 30000; which is used as timeout for async request.

@Configuration
class TomcatAsyncConfig {
    @Bean
    fun asyncTimeoutCustomize(): TomcatConnectorCustomizer =
        TomcatConnectorCustomizer { connector -> connector.asyncTimeout = 180000 }
}

Modifing values of spring.mvc.async.request-timeout: -1 or server.tomcat.connection-timeout won't do.

Vaclav Stengl
  • 359
  • 3
  • 8