jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Client: Some HTTP/2 requests are never sent

Open mperktold opened this issue 7 months ago • 0 comments

Jetty version(s) Jetty 12.0.10

Jetty Environment core

Java version/vendor (use: java -version) openjdk version "21.0.3" 2024-04-16 LTS OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)

OS type/version Windows 11

Description When using the Jetty 12 HttpClient to send a request to certain servers via HTTP/2, the request never completes. In fact, the request is only queued, but sending the request never even begins.

This only happens with some servers, which do support HTTP/2.

How to reproduce?

var connector = new ClientConnector();
connector.setSslContextFactory(new SslContextFactory.Client());
var httpClient = new HttpClient(new HttpClientTransportDynamic(connector,
    HttpClientConnectionFactory.HTTP11,
    new ClientConnectionFactoryOverHTTP2.HTTP2(new HTTP2Client(connector))
));
httpClient.start();
ContentResponse response = httpClient.newRequest("https://microsoft.sharepoint.com")
    .onRequestQueued(r -> System.out.println("request queued"))
    .onRequestBegin(r -> System.out.println("request begin"))
    .onRequestContent((r, c) -> System.out.println("request content"))
    .onRequestSuccess(r -> System.out.println("request success"))
    .onResponseBegin(r -> System.out.println("response begin"))
    .onResponseContent((r, c) -> System.out.println("response content"))
    .onResponseSuccess(r -> System.out.println("response success"))
    .send();
System.out.println(response);
httpClient.stop();

The above snippet creates a HttpClient that supports both HTTP/1.1 and HTTP2, and makes a request to "https://microsoft.sharepoint.com". Several events are logged, so we see that the request is only ever queued, but never sent.

When forcing the client to use HTTP/1.1, either by removing support for HTTP/2, or by using version(HttpVersion.HTTP_1_1), everything works as expected.

Also, the following curl command sends the same request, also using HTTP/2, and works fine: curl "https://microsoft.sharepoint.com" --http2

mperktold avatar Jun 26 '24 16:06 mperktold