Skip to content

Commit a755c0d

Browse files
Merge pull request #227485 from ealsur/users/ealsur/timeout2
Adding opentcptimeout on SDK doc
2 parents a35c374 + e09ecb6 commit a755c0d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

articles/cosmos-db/nosql/troubleshoot-dotnet-sdk-request-timeout.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to diagnose and fix .NET SDK request timeout exceptions.
44
author: seesharprun
55
ms.service: cosmos-db
66
ms.subservice: nosql
7-
ms.date: 09/16/2022
7+
ms.date: 02/15/2023
88
ms.author: sidandrews
99
ms.topic: troubleshooting
1010
ms.reviewer: mjbrown
@@ -28,13 +28,17 @@ When evaluating the case for timeout errors:
2828

2929
The SDK has two distinct alternatives to control timeouts, each with a different scope.
3030

31-
### RequestTimeout
31+
### Request level timeouts
3232

33-
The `CosmosClientOptions.RequestTimeout` (or `ConnectionPolicy.RequestTimeout` for SDK v2) configuration allows you to set a timeout that affects each individual network request. An operation started by a user can span multiple network requests (for example, there could be throttling). This configuration would apply for each network request on the retry. This timeout isn't an end-to-end operation request timeout.
33+
The `CosmosClientOptions.RequestTimeout` (or `ConnectionPolicy.RequestTimeout` for SDK v2) configuration allows you to set a timeout for the network request after the request left the SDK and is on the network, until a response is received.
34+
35+
The `CosmosClientOptions.OpenTcpConnectionTimeout` (or `ConnectionPolicy.OpenTcpConnectionTimeout` for SDK v2) configuration allows you to set a timeout for the time spent opening an initial connection. Once a connection is opened, subsequent requests will use the connection.
36+
37+
An operation started by a user can span multiple network requests, for example, retries. These two configurations are per-request, not end-to-end for an operation.
3438

3539
### CancellationToken
3640

37-
All the async operations in the SDK have an optional CancellationToken parameter. This [CancellationToken](/dotnet/standard/threading/how-to-listen-for-cancellation-requests-by-polling) parameter is used throughout the entire operation, across all network requests. In between network requests, the cancellation token might be checked and an operation canceled if the related token is expired. The cancellation token should be used to define an approximate expected timeout on the operation scope.
41+
All the async operations in the SDK have an optional CancellationToken parameter. This [CancellationToken](/dotnet/standard/threading/how-to-listen-for-cancellation-requests-by-polling) parameter is used throughout the entire operation, across all network requests and retries. In between network requests, the cancellation token might be checked and an operation canceled if the related token is expired. The cancellation token should be used to define an approximate expected timeout on the operation scope.
3842

3943
> [!NOTE]
4044
> The `CancellationToken` parameter is a mechanism where the library will check the cancellation when it [won't cause an invalid state](https://devblogs.microsoft.com/premier-developer/recommended-patterns-for-cancellationtoken/). The operation might not cancel exactly when the time defined in the cancellation is up. Instead, after the time is up, it cancels when it's safe to do so.
@@ -53,7 +57,7 @@ These exceptions are safe to retry on and can be treated as [timeouts](conceptua
5357

5458
#### Solution
5559

56-
Verify the configured time in your `CancellationToken`, make sure that it's greater than your [RequestTimeout](#requesttimeout) and the [CosmosClientOptions.OpenTcpConnectionTimeout](/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.opentcpconnectiontimeout) (if you're using [Direct mode](sdk-connection-modes.md)).
60+
Verify the configured time in your `CancellationToken`, make sure that it's greater than your [RequestTimeout](#request-level-timeouts) and the [CosmosClientOptions.OpenTcpConnectionTimeout](/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.opentcpconnectiontimeout) (if you're using [Direct mode](sdk-connection-modes.md)).
5761
If the available time in the `CancellationToken` is less than the configured timeouts, and the SDK is facing [transient connectivity issues](conceptual-resilient-sdk-applications.md#timeouts-and-connectivity-related-failures-http-408503), the SDK won't be able to retry and will throw `CosmosOperationCanceledException`.
5862

5963
### High CPU utilization

0 commit comments

Comments
 (0)