3

I am using an embedded jetty container using spring boot. If my request take too long, Jetty fails on 503. In jetty logs I see this:

Dispatch after async timeout

So, I assume the async timed out. However, I couldn't find where to update this timeout to a higher value.

Any ideas?

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
YaOg
  • 1,748
  • 5
  • 24
  • 43
  • Async Timeout can refer to Async Processing (aka AsyncContext from Servlet 3.0) or Async I/O (from Servlet 3.1). Which one are you concerned about? – Joakim Erdfelt Aug 09 '16 at 14:10
  • Judging from the debugging I did it refers to the AsyncContext. – YaOg Aug 09 '16 at 21:17

2 Answers2

4

You can add a JettyServerCustomizer to your application context to customize Jetty:

@Bean
JettyServerCustomizer jettyCustomizer() {
    return new JettyServerCustomizer() {
        @Override
        public void customize(Server server) {
            //do something
        }
    };
}

But the configuration you're looking for I think is at the AsyncContext level, and that's handled by Spring MVC. Try this configuration:

@Configuration
public static class MvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
        configurer.setDefaultTimeout(60000);
    }
 }
Ulises
  • 9,115
  • 2
  • 30
  • 27
4

Spring mvc supports an application property, spring.mvc.async.request-timeout, which is the timeout in milliseconds for asynchronous request handling. Verified with spring-webmvc-4.3.2.RELEASE

Belle
  • 56
  • 3