Projects tigase _server tigase-http-api Issues #167
Async request timeout (def: 30s) (#167)
Wojciech Kapcia (Tigase) opened 4 days ago

We do have an option to limit request timeout, e.g.:

httpServer () {
    'request-timeout' = 120000
}

However, it seems it doesn't work with asynchronous execution.

The assumption would be that AsyncContext asyncCtx = request.startAsync(request, response); either would:

  • not have any timeout (and the handler deals with it on it's own); or
  • use the global Jetty ServerConnector timeout set with connector.setIdleTimeout(timeout);

It turns out, that neither is true and if the timeout is not set explicity (or disabled with 0) then it would use the default. As per javax.servlet.AsyncContext#setTimeout documentation (link to jakarta even though Tigase 8.x still uses javax but the thing didn't change):

The timeout applies to this AsyncContext once the container-initiated dispatch during which one of the ServletRequest.startAsync() methods was called has returned to the container.

The timeout will expire if neither the complete() method nor any of the dispatch methods are called. A timeout value of zero or less indicates no timeout.

If setTimeout(long) is not called, then the container's default timeout, which is available via a call to getTimeout(), will apply.

The default value is 30000 ms.

[2025-08-12 11:10:18.647] [INFO ] [                main] t.h.j.JettyStandaloneHttpServer.createConnector(): Setting request timeout to 120000 ms
…
[2025-08-12 11:10:18.647] [INFO ] [                main] t.h.j.JettyStandaloneHttpServer.createConnector(): Setting request timeout to 120000 ms
[2025-08-12 11:10:28.381] [INFO ] [   qtp1068380229-435] t.h.m.r.OldGroovyRequestHandler.executeAsync(): Async context timeout: 30000 for request: Request(POST //localhost:8080/rest/…)@17da9ee6
…
[2025-08-12 11:11:00.303] [DEBUG] [Connector-Scheduler-54db0281-1] o.e.j.s.HttpChannelState.timeout(): Dispatch after async timeout HttpChannelState@1d48c0db{s=WOKEN rs=EXPIRE os=OPEN is=IDLE awp=false se=false i=false al=0}

It seems this mostly applies to async groovy rest handlers, which should define it's own timeout and make a call to the callback when it finishes so possibly the async handling should respect that, thus setting it by asyncCtx.setTimeout(0) in tigase.http.modules.rest.OldGroovyRequestHandler#executeAsync would be one solution. However, in case of impropper handling it would lead to requests hanging thus having follow global timeout seems more correct.

@andrzej.wojcik However, most of it will be removed in 9.0 so maybe silly workaround for 8.x in tigase.http.jetty.JettyStandaloneHttpServer#createConnector(org.eclipse.jetty.server.Server, tigase.http.jetty.JettyStandaloneHttpServer.PortConfigBean):

System.setProperty("org.eclipse.jetty.server.HttpChannelState.DEFAULT_TIMEOUT", String.valueOf(timeout));

Would be enough?

  • Wojciech Kapcia (Tigase) added "Related" tigase-private/tigase-licenceserver#65 4 days ago
  • Wojciech Kapcia (Tigase) changed state to 'In Progress' 4 days ago
    Previous Value Current Value
    Open
    In Progress
  • Andrzej Wójcik (Tigase) commented 4 days ago

    I would go with suggested simple workaround for 8.x and work on that in the future versions.

  • Wojciech Kapcia (Tigase) commented 4 days ago

    Thank you. Implemented as suggested.

  • Wojciech Kapcia (Tigase) changed state to 'Closed' 4 days ago
    Previous Value Current Value
    In Progress
    Closed
issue 1 of 1
Type
Task
Priority
Normal
Assignee
Version
none
Sprints
n/a
Customer
n/a
Iterations
Issue Votes (0)
Watchers (3)
Reference
tigase/_server/tigase-http-api#167
Please wait...
Page is in error, reload to recover