Search code examples
javaembedded-jettyhttp2

Jetty http/2 client hangs fetching url


I have a code (actually, copied from jetty-project repo):

HTTP2Client http2Client = new HTTP2Client();
SslContextFactory sslContextFactory = new SslContextFactory();
HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), sslContextFactory);
Executor executor = new QueuedThreadPool();
httpClient.setExecutor(executor);
httpClient.start();

ContentResponse response = httpClient.GET("https://www.google.com/");

For some reason it waits for response infinitely. What's the problem with it? I'm seeking for a working example of http/2 client usage to access some https url. Thanks!


Solution

  • You probably did not configure ALPN.

    Please refer to the ALPN documentation to enable ALPN for the JVM running your client code.