gpt4 book ai didi

java - HTTP/2 和 jetty : Max local stream count 100 exceeded

转载 作者:行者123 更新时间:2023-12-01 10:36:04 25 4
gpt4 key购买 nike

在使用基本的 HTTP/2 GET 请求时,Jetty 似乎没有重用其内部流。大约 100 个请求后,它抛出以下异常:

Caused by: java.lang.IllegalStateException: Max local stream count 100 exceeded
at org.eclipse.jetty.http2.HTTP2Session.createLocalStream(HTTP2Session.java:614)
at org.eclipse.jetty.http2.HTTP2Session.newStream(HTTP2Session.java:430)
at org.eclipse.jetty.http2.client.http.HttpSenderOverHTTP2.sendHeaders(HttpSenderOverHTTP2.java:86)
at org.eclipse.jetty.client.HttpSender.send(HttpSender.java:204)
at org.eclipse.jetty.http2.client.http.HttpChannelOverHTTP2.send(HttpChannelOverHTTP2.java:73)
at org.eclipse.jetty.http2.client.http.HttpConnectionOverHTTP2.send(HttpConnectionOverHTTP2.java:52)
at org.eclipse.jetty.http2.client.http.HttpDestinationOverHTTP2.send(HttpDestinationOverHTTP2.java:36)
at org.eclipse.jetty.http2.client.http.HttpDestinationOverHTTP2.send(HttpDestinationOverHTTP2.java:26)
at org.eclipse.jetty.client.MultiplexHttpDestination.process(MultiplexHttpDestination.java:117)
at org.eclipse.jetty.client.MultiplexHttpDestination.send(MultiplexHttpDestination.java:59)
at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:199)
at org.eclipse.jetty.client.HttpClient.send(HttpClient.java:538)
at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:694)
at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:647)
... 8 more

我使用的代码如下:

HTTP2Client http2Client = new HTTP2Client();
http2Client.start();

HttpClient client = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), ssl);
client.start();

for (int i = 0; i < 1000; i++) {
System.out.println(i);
ContentResponse response = client.GET("https://http2.akamai.com");
System.out.println("response code: " + response.getStatus());
}

我进一步研究了 Jetty 的源代码,它为每个请求创建一个新的流。为什么会这样?

我有什么遗漏的吗?这使得它几乎无法用于 API 请求等。

最佳答案

您遇到了一个已修复的错误。

请更新到 Jetty 9.3.7.RC0 或更高版本。

谢谢!

关于java - HTTP/2 和 jetty : Max local stream count 100 exceeded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34717793/

25 4 0