Repository navigation
Description
Background and motivation
HTTP/2 has an inherent race condition during connection establishment.
The stream limit is advertised by the server in a SETTINGS frame, but the client is free to send requests immediately after a connection is established, even before it observes the settings.
As a result the client may send more requests than the server limit, which causes many of those requests to fail. Some may be successfully retried, but in some scenarios not all of them are retriable, and the act of sending too many requests may already trip server-side DoS mitigations.
Since .NET 11 SocketsHttpHandler has a new heuristic where we'll remember the last advertised stream limit for a given host, and avoid exceeding it on future connections. This solves the issue when the server advertises a consistent low limit on all connections, but does nothing for situations where the stream limit is dynamic on every individual connection.
I'm proposing we expose an API which allows you to configure the initial stream limit, and we'll use that for new connections.
If it's not set we'll fall back to the heuristic, and if we haven't observed a SETTINGS frame yet, to 100, as we do today.
The proposed property is nullable to distinguish between the property being set manually vs. using our own internal default of 100.
The setting name from the spec is SETTINGS_MAX_CONCURRENT_STREAMS.
API Proposal
namespace System.Net.Http;
public partial class SocketsHttpHandler
{
// Existing
// public int InitialHttp2StreamWindowSize { get; set; }
// public bool EnableMultipleHttp2Connections { get; set; }
public int? InitialHttp2MaxConcurrentStreams { get; set; }
}API Usage
var handler = new SocketsHttpHandler();
// Start with 1, making it impossible to exceed the server limit.
// Concurrency will adjust up automatically once the real server limit is received.
handler.InitialHttp2MaxConcurrentStreams = 1;Alternative Designs
Expose the knob via AppContext/environment variables instead.
Risks
No response
Activity
dotnet-policy-service commentedon Aug 18, 2026
Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.
bartonjs commentedon Aug 18, 2026
Video
[release/11.0] Implement SocketsHttpHandler.InitialHttp2MaxConcurrent…
MihaZupan commentedon Aug 26, 2026
Implemented for .NET 12 in #132521, and backported to .NET 11 RC2 in #132566.