spring-projects / spring-boot

Spring Boot helps you to create Spring-powered, production-grade applications and services with absolute minimum fuss.
https://spring.io/projects/spring-boot
Apache License 2.0
75.26k stars 40.7k forks source link

Invasive AsyncRequestTimeoutException #14237

Closed akuma8 closed 6 years ago

akuma8 commented 6 years ago

In my app, since I added this simple controller handler:

   @GetMapping("/sse")
    SseEmitter registerClient(){
      SseEmitter emitter = new SseEmitter();
      // emitter is then stored in a concurrentHashMap
      return emitter;
    }

Every 10s I have this exception:

org.springframework.web.context.request.async.AsyncRequestTimeoutException: null
    at org.springframework.web.context.request.async.TimeoutDeferredResultProcessingInterceptor.handleTimeout(TimeoutDeferredResultProcessingInterceptor.java:42)
    at org.springframework.web.context.request.async.DeferredResultInterceptorChain.triggerAfterTimeout(DeferredResultInterceptorChain.java:79)
    at org.springframework.web.context.request.async.WebAsyncManager.lambda$startDeferredResultProcessing$5(WebAsyncManager.java:426)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at org.springframework.web.context.request.async.StandardServletAsyncWebRequest.onTimeout(StandardServletAsyncWebRequest.java:151)
    at org.apache.catalina.core.AsyncListenerWrapper.fireOnTimeout(AsyncListenerWrapper.java:44)
    at org.apache.catalina.core.AsyncContextImpl.timeout(AsyncContextImpl.java:136)
    at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:153)
    at org.apache.coyote.AbstractProcessor.dispatch(AbstractProcessor.java:236)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

And the client API (JavaScript EventSource()) continue to send a GET request and goes on error everytime. Some says to add this property: spring.mvc.async.request-timeout=-1 but I think this could have some side effects. What's going wrong? I am using Spring Boot 2.0.4.RELEASE

snicoll commented 6 years ago

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

akuma8 commented 6 years ago

Thanks for your answer. I already posted it in Stack OverFlow but no one answer it yet: here the link As it is becoming annoying and I don't see the reason I thought it could be a bug.

snicoll commented 6 years ago

@akuma8 please do not cross post, especially without specifying you've done so as several people may try to help you in different channels. Your SO question would have a much better visibility if you took to the time to create a minimal, complete, and verifiable example.