Netty servers: handle requestTimeout properly, add idleTimeout#3815
Merged
Conversation
kciesielski
commented
Jun 3, 2024
adamw
reviewed
Jun 4, 2024
adamw
reviewed
Jun 4, 2024
adamw
approved these changes
Jun 4, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3795
This PR replaces usage of
ReadTimeoutHandlerwithIdleStateHandler.The
ReadStateHandlerwas configured usingNettyConfig.requestTimeoutvalue, but it wasn't serving the purpose of failing when there is no response within given timeout. This handler throws an exception when there is no data read , which means no request from the client.We will be using
IdleStateHandlerto deal with timeouts correctly:nettyConfig.requestTimeout. If it expires, the channel is closed, a HTTP 503 response is returned, and in-flight requests in the channel are canceled. An error is logged.NettyConfig.idleTimeout. Similarly to idle-timeout in akka-http, it defines a time of no reads nor writes, after which the channel will be closed silently (only with a debug log). This is a "normal situation" that may happen after a long-running keep-alive connection expires (typically from a web browser), like in io.netty.handler.timeout.ReadTimeoutException logged for a simple endpoint #3795, which initiated this work.idleTimeoutis set by default to 60s, whilerequestTimeoutis 20s.