Skip to content

HTTP2: New calls blocking on SETTINGS_MAX_CONCURRENT_STREAMS #30596

Closed
@JamesNK

Description

@JamesNK

If I start 100 duplex streaming calls using HttpClient on a server where SETTINGS_MAX_CONCURRENT_STREAMS = 100, the 101st will block until one is closed:

var calls = new List<AsyncDuplexStreamingCall<DataMessage, DataMessage>>();

for (int i = 1; i < 1000; i++)
{
    Logger.LogInformation($"ITERATION {i}");

    // The streaming call stays open forever
    var call = client.DuplexStreamingCall();

    // Blocks on 101st iteration
    await call.ResponseHeadersAsync.DefaultTimeout();

    calls.Add(call);
}

Right now a user has two options:

  1. Simple solution is to configure Kestrel (or whatever other HTTP/2 server they are talking to) to have an unlimited SETTINGS_MAX_CONCURRENT_STREAMS.
  2. If a user doesn't control the server then they either have to use a separate HttpClient instance for each call (1 connection = 1 stream), or try to count the number of calls in progress and manage a pool of HttpClient instances.

Neither seem like ideal solutions. What is the best fix? Should there be an option on HttpClientHandler to start a new connection when max concurrent streams is hit instead of blocking? Related: https://github.com/dotnet/corefx/issues/32303

// @stephentoub @geoffkizer @wfurt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions