Netty servers: handle requestTimeout properly, add idleTimeout #3815
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
ReadTimeoutHandler
withIdleStateHandler
.The
ReadStateHandler
was configured usingNettyConfig.requestTimeout
value, 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
IdleStateHandler
to 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.idleTimeout
is set by default to 60s, whilerequestTimeout
is 20s.