judepereira
judepereira

Reputation: 1297

HTTP/2 and Jetty: Max local stream count 100 exceeded

On using a basic HTTP/2 GET request, Jetty doesn't seem to reuse it's internal streams. After about 100 requests, it throws the exception below:

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

The code I'm using is as follows:

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());
}

I further went into Jetty's source code, and it creates a new stream for every request. Why is this so?

Is there something I'm missing? This makes it pretty much unusable for API requests, etc.

Upvotes: 0

Views: 539

Answers (1)

sbordet
sbordet

Reputation: 18552

You hit a bug that has been fixed.

Please update to Jetty 9.3.7.RC0 or later.

Thanks !

Upvotes: 1

Related Questions