Delen via


CosmosClientBuilder.WithConnectionModeDirect Method

Definition

Overloads

WithConnectionModeDirect(Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<Int32>, Nullable<Int32>, Nullable<PortReuseMode>, Nullable<Boolean>)

Sets the connection mode to Direct. This is used by the client when connecting to the Azure Cosmos DB service.

WithConnectionModeDirect()

Sets the connection mode to Direct. This is used by the client when connecting to the Azure Cosmos DB service.

WithConnectionModeDirect(Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<Int32>, Nullable<Int32>, Nullable<PortReuseMode>, Nullable<Boolean>)

Source:
CosmosClientBuilder.cs

Sets the connection mode to Direct. This is used by the client when connecting to the Azure Cosmos DB service.

public Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder WithConnectionModeDirect (TimeSpan? idleTcpConnectionTimeout = default, TimeSpan? openTcpConnectionTimeout = default, int? maxRequestsPerTcpConnection = default, int? maxTcpConnectionsPerEndpoint = default, Microsoft.Azure.Cosmos.PortReuseMode? portReuseMode = default, bool? enableTcpConnectionEndpointRediscovery = default);
member this.WithConnectionModeDirect : Nullable<TimeSpan> * Nullable<TimeSpan> * Nullable<int> * Nullable<int> * Nullable<Microsoft.Azure.Cosmos.PortReuseMode> * Nullable<bool> -> Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder
Public Function WithConnectionModeDirect (Optional idleTcpConnectionTimeout As Nullable(Of TimeSpan) = Nothing, Optional openTcpConnectionTimeout As Nullable(Of TimeSpan) = Nothing, Optional maxRequestsPerTcpConnection As Nullable(Of Integer) = Nothing, Optional maxTcpConnectionsPerEndpoint As Nullable(Of Integer) = Nothing, Optional portReuseMode As Nullable(Of PortReuseMode) = Nothing, Optional enableTcpConnectionEndpointRediscovery As Nullable(Of Boolean) = Nothing) As CosmosClientBuilder

Parameters

idleTcpConnectionTimeout
Nullable<TimeSpan>

Controls the amount of idle time after which unused connections are closed. By default, idle connections are kept open indefinitely. Value must be greater than or equal to 10 minutes. Recommended values are between 20 minutes and 24 hours. Mainly useful for sparse infrequent access to a large database account.

openTcpConnectionTimeout
Nullable<TimeSpan>

Controls the amount of time allowed for trying to establish a connection. The default timeout is 5 seconds. Recommended values are greater than or equal to 5 seconds. When the time elapses, the attempt is cancelled and an error is returned. Longer timeouts will delay retries and failures.

maxRequestsPerTcpConnection
Nullable<Int32>

Controls the number of requests allowed simultaneously over a single TCP connection. When more requests are in flight simultaneously, the direct/TCP client will open additional connections. The default settings allow 30 simultaneous requests per connection. Do not set this value lower than 4 requests per connection or higher than 50-100 requests per connection.
The former can lead to a large number of connections to be created. The latter can lead to head of line blocking, high latency and timeouts. Applications with a very high degree of parallelism per connection, with large requests or responses, or with very tight latency requirements might get better performance with 8-16 requests per connection.

maxTcpConnectionsPerEndpoint
Nullable<Int32>

Controls the maximum number of TCP connections that may be opened to each Cosmos DB back-end. Together with MaxRequestsPerTcpConnection, this setting limits the number of requests that are simultaneously sent to a single Cosmos DB back-end(MaxRequestsPerTcpConnection x MaxTcpConnectionPerEndpoint). The default value is 65,535. Value must be greater than or equal to 16.

portReuseMode
Nullable<PortReuseMode>

(Direct/TCP) Controls the client port reuse policy used by the transport stack. The default value is PortReuseMode.ReuseUnicastPort.

enableTcpConnectionEndpointRediscovery
Nullable<Boolean>

(Direct/TCP) Controls the address cache refresh on TCP connection reset notification. The default value is false.

Returns

The current CosmosClientBuilder.

Remarks

For more information, see Connection policy: Use direct connection mode.

See also

Applies to

WithConnectionModeDirect()

Source:
CosmosClientBuilder.cs

Sets the connection mode to Direct. This is used by the client when connecting to the Azure Cosmos DB service.

public Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder WithConnectionModeDirect ();
member this.WithConnectionModeDirect : unit -> Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder
Public Function WithConnectionModeDirect () As CosmosClientBuilder

Returns

The current CosmosClientBuilder.

Remarks

For more information, see Connection policy: Use direct connection mode.

See also

Applies to