New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Servlet 3.1 ReadListener.onAllDataRead() is called twice under h2 or h2c if the server doesn't respond within 30s #8405
Comments
…calls to grpc (#2717) Combined with #2401, the Jetty-based server can now directly offer grpc-web (albeit without support for text payloads). While technically this works with http/1.1 connections, it is best suited for h/2, so the JS API still defaults to the existing websocket transport when https is not present. See https://github.com/grpc/grpc/blob/v1.48.0/doc/PROTOCOL-WEB.md Also includes a workaround for jetty/jetty.project#8405. Fixes #1769
Looks like grpc added support for Jetty Servlet 4+ (javax and jakarta) but are hitting this as a bug. |
It looks as though this is related to Setting the stream idle timeout to very large values will presumably just delay the time until the unexpected behavior takes place. |
@niloc132 thank you for the detailed report, it is indeed a bug. Standby for a fix. |
…times out Per Servlet semantic, HTTP/2 stream timeout should be ignored. The code was trying to fail the read via `_contentDemander.onTimeout()`, but then it was still calling `onContentProducible()`, which was returning `true` because the state of the read was IDLE (all the request content was read) and the request was suspended. Now the code checks if the read was really failed; if it is not, then `onContentProducible()` is not called and so the idle timeout is ignored. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
#10174) * Fixes #8405 - onAllDataRead() is called twice under h2 if the stream times out Per Servlet semantic, HTTP/2 stream timeout should be ignored. The code was trying to fail the read via `_contentDemander.onTimeout()`, but then it was still calling `onContentProducible()`, which was returning `true` because the state of the read was IDLE (all the request content was read) and the request was suspended. Now the code checks if the read was really failed; if it is not, then `onContentProducible()` is not called and so the idle timeout is ignored. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Jetty version(s)
tested 11.0.8, 11.0.11
Java version/vendor
(use: java -version)
OS type/version
Linux
Description
Steps to reproduce:
Expected behavior is that the
onAllDataRead
only happens once (immediately after the client half-closes), but the actual behavior is that the listener gets a secondonAllDataRead
call, 30s after the first one. Note that it seems likely that this value is configuration or platform dependent and if so, the note above about "do not send a response from the server for 30 seconds") likely also depends on this.Verified with a web browser as a client (note that h2c isn't an option for web browsers, and the bug does not happen with http/1.1), and also with curl commands (with flags to force http2 and allow insecure localhost certs):
curl -k -XPOST https://localhost:8443/stream
curl --http2-prior-knowledge -XPOST http://localhost:8080/stream
How to reproduce?
Example servlet:
A sample main() that enables both h2c and https, and the above servlet. This expects a app/index.html so a browser can experience the bug as well, also attached below. Note that if the SSL section is enabled, a keystore will be required.
Simple HTML file to load the stream and log messages as they arrive:
The text was updated successfully, but these errors were encountered: