Skip to content

Improve internal handling of timeouts, make max timeout configurable - #244

Merged
RalphBln merged 1 commit into
mainfrom
fix/internal-timeout
Oct 30, 2026
Merged

RalphBln merged 1 commit into
mainfrom
fix/internal-timeout

Conversation

@RalphBln

Copy link
Copy Markdown
Collaborator

This PR solves an issue with conflicting timeout settings on different layers of the application.

Spring Boot's internal Tomcat server, which handles all client requests to the API gateway, has its default request timeout set to 30 seconds, while the default API Gateway timeout for requests to connected providers is set to 60 seconds.

In case a federated query took longer than Tomcat's timeout, Tomcat would close the connection to the client prematurely, while the federated request would still be processed in the API gateway. The requested API gateway endpoint would then try to write its response to the client via the meanwhile closed socket, which resulted in an AsyncRequestNotUsableException.

This PR solves the issues by introducing the following changes:

  1. We now explicitly set Tomcat's request timeout and make sure it is slightly longer than the API gateway's default timeout (API gateway timeout + 10 seconds).
  2. In order to avoid situations where API gateway users select a timeout that is longer than Tomcat's request timeout via the timeout request parameter, we now restrict the maximum value of the timeout request parameters to the API gateway's default timeout, making the API gateway default timeout the maximum timeout.
  3. We make the API gateway's default (=maximum) timeout value configurable in the application.properties file via the application.timeout_ms.maxvalue property. The value can also be set from outside via the environment variable REQUEST_TIMEOUT_MS_MAXVALUE. If the variable does not exist the application falls back to a predefined value of 60 seconds (60,000 milliseconds).

Internally, this brought about some internal API changes, especially in the ApiAccessor and the services that instantiate it. Some tests needed to be adapted to the changes.

@RalphBln
RalphBln requested a review from jusa3 October 29, 2026 20:04
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 52.77778% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...cs/apigateway/service/AbstractEndpointService.java 46.15% 6 Missing and 1 partial ⚠️
...teway/artefacts/tree/ArtefactsDataTreeService.java 0.00% 5 Missing ⚠️
...tics/apigateway/controller/ols/Ols3Controller.java 0.00% 3 Missing ⚠️
...ics/apigateway/artefacts/search/SearchService.java 50.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@RalphBln

Copy link
Copy Markdown
Collaborator Author

Note: This popped up because the LovPortal seems to have issues at the moment. Requests to it never return leading to the situation with Tomcat closing the client connection prematurely after 30 seconds before the API gateway gives up after its own 60 second timeout.

@RalphBln
RalphBln merged commit dc1b12d into main Oct 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants