Jetty http / 2客户端挂起获取URL

时间:2017-05-29 15:51:16

标签: java embedded-jetty http2

我有一个代码(实际上是从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/");

由于某种原因,它无限期地等待响应。有什么问题呢?我正在寻找一个http / 2客户端使用的工作示例来访问一些https网址。谢谢!

1 个答案:

答案 0 :(得分:1)

您可能没有配置ALPN。

请参阅ALPN documentation为运行客户端代码的JVM启用ALPN。