jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
https://eclipse.dev/jetty
Other
3.88k stars 1.91k forks source link

Timeout on reading from Request with HTTPS and HTTP/2 #6284

Closed mperktold closed 3 years ago

mperktold commented 3 years ago

Jetty version 10.0.2

Java version/vendor openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

OS type/version Windows 10, 64 bit

Description When upgrading our Vaadin application from Jetty 9.4 to 10, it stopped working properly if accessed via HTTPS and HTTP/2. It the initial screen is loaded fine, but when the client tries to send another request, the server never answers.

I've reproduces the issue in mperktold/vaadin14-embedded-jetty, which is a fork of mvysny/vaadin14-embedded-jetty. It is basically a "Hello World" Vaadin application running in an embedded Jetty server, which is started programmatically. In my fork, I've upgraded it to Jetty 10.0.2, Java 11, and Vaadin 19, and enabled HTTPS and HTTP/2 support. It loads fine, but when clicking "Say hello", the browser tries to send the click event to the server for being handled, but never gets a response. I've tested this with Chrome and Firefox, both with the same result.

When disabling HTTP/2, everything works fine. In the branch jetty-9, I downgraded to Jetty 9 again but kept the HTTPS and HTTP/2 support, and there everything works fine as well.

So far, my understanding is that after initializing the page, the browser sends an RST_STREAM (for whatever reason), so the Jetty server resets the connection. When receiving the next request of the same kind, Jetty fails to read the content. It tries to asynchronously read the whole request before passing it to the application, but fails. Then it passes the request to the application, which reads from the input stream, and gets a TimeoutException. Other kinds of requests still get handled correctly though, maybe because they are send over another connection?

I am not sure who is misbehaving, the browser, Jetty, Vaadin, or my configuration, but I thought that at least you have the best chance of understanding what is going on here.

sbordet commented 3 years ago

@mperktold your project builds, but fails to start for me with:

com.vaadin.flow.server.frontend.FrontendUtils$UnknownVersionException: Unable to detect version of pnpm. Using command --yes --quiet pnpm@5 --version

and

ava.lang.IllegalStateException: com.vaadin.flow.server.ExecutionFailedException: Found too old 'pnpm'. If installed into the project 'node_modules', upgrade 'pnpm' to at least 5.0.0
    at com.vaadin.flow.server.DevModeHandler.getCause(DevModeHandler.java:267)
    at com.vaadin.flow.server.DevModeHandler.getCause(DevModeHandler.java:263)
    at com.vaadin.flow.server.DevModeHandler.handleRequest(DevModeHandler.java:249)
    at com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1556)
    at com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:299)
mperktold commented 3 years ago

Interesting, I'll see if I can fix that.

mperktold commented 3 years ago

I cannot reproduce this problem, but we can try it with NPM instead of PNPM. You just have to change the system property to false in Main.start:

System.setProperty("vaadin.pnpm.enable", "false");

If a node_modules directory was created before, you should probably delete it before trying with NPM.

mperktold commented 3 years ago

In the meantime, some more information:

Vaadin uses websockets. The project doesn't use them, but apparently an initial "hello" message is sent anyway. Maybe that's the reason why an RST_STREAM is sent?

Also, I've tried a SNAPSHOT of the upcoming 10.0.3 of Jetty, but that didn't help.

sbordet commented 3 years ago

@mperktold we can reproduce the issue, thanks for the reproducer! We are working on a fix and we'll keep this issue updated on our findings.

lorban commented 3 years ago

Thank you for the reproducer, it helped us figure out where the problem is much quicker.

Thanks to it, I quickly found that 10.0.0 is not impacted by this bug while 10.0.1 is so it got introduced somewhere between these two revisions. Bisecting then helped me pinpoint the actual change that introduced this problem: https://github.com/eclipse/jetty.project/commit/d297e9c4731a66ca198094e0fe3f2628c41c6d9a

Since the problem has been identified, we can now work on a fix. We'll keep you posted about our progress.

mperktold commented 3 years ago

Thank you for the reproducer, it helped us figure out where the problem is much quicker.

Great, I'm glad it's useful!

Thanks to it, I quickly found that 10.0.0 is not impacted by this bug

That's good to know, thanks! Still, we will probably stay on 9.4 and wait for 10.0.4.

On that note, is there a tentative release date? In the corresponding GitHub project, there are still quite a few issues in the to-do state.

sbordet commented 3 years ago

@mperktold the project you reference is for the next-next release, 1x.0.4. We still have to release 1x.0.3, which will happen in the next days, with this fix included.

Are you able to try branch jetty-10.0.x-6284-h2-timeout and report back if it works for you?

lorban commented 3 years ago

FYI, I just merged the jetty-10.0.x-6284-h2-timeout branch into jetty-10.0.x then deleted it so the latter is now the branch you want to try out.

mperktold commented 3 years ago

That's great news!

I just tried branch jetty-10.0.x, it works fine now, thanks!

sbordet commented 3 years ago

@mperktold thanks for confirming!