CosmosClientOptions.GatewayModeMaxConnectionLimit Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Get or set the maximum number of concurrent connections allowed for the target service endpoint in the Azure Cosmos DB service.
public int GatewayModeMaxConnectionLimit { get; set; }
member this.GatewayModeMaxConnectionLimit : int with get, set
Public Property GatewayModeMaxConnectionLimit As Integer
Property Value
Default value is 50.
Examples
Using the SDK-managed handler with a custom connection limit:
CosmosClientOptions options = new CosmosClientOptions()
{
ConnectionMode = ConnectionMode.Gateway,
GatewayModeMaxConnectionLimit = 100
};
When providing a custom HttpClientFactory, set the properties on SocketsHttpHandler directly:
SocketsHttpHandler handler = new SocketsHttpHandler
{
MaxConnectionsPerServer = 100,
EnableMultipleHttp2Connections = true
};
CosmosClientOptions options = new CosmosClientOptions()
{
HttpClientFactory = () => new HttpClient(handler, disposeHandler: false)
};
Remarks
This setting is only applicable in Gateway mode. The SDK sets EnableMultipleHttp2Connections = true on the underlying SocketsHttpHandler, allowing additional HTTP/2 TCP connections to be opened when the maximum concurrent streams limit on an existing connection is reached. This property controls the upper bound on the total number of connections per server endpoint. When using a custom HttpClientFactory, set EnableMultipleHttp2Connections directly on your SocketsHttpHandler for equivalent behavior.