Skip to content

Commit b3c3524

Browse files
Merge pull request #228665 from seesharprun/cosmos-update-troubleshooting
Cosmos DB | Freshness update - top 10 articles - #1
2 parents 7b0d5bf + 15af6e0 commit b3c3524

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed
Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,64 @@
11
---
2-
title: Troubleshoot a "Request header too large" message or 400 bad request in Azure Cosmos DB
3-
description: Learn how to diagnose and fix the request header too large exception.
2+
title: Troubleshoot "request header too large" or "bad request"
3+
titleSuffix: Azure Cosmos DB
4+
description: Learn how to diagnose and fix either the HTTP request header too large or bad request (400) exceptions.
45
author: seesharprun
6+
ms.author: sidandrews
7+
ms.reviewer: mjbrown
58
ms.service: cosmos-db
69
ms.subservice: nosql
7-
ms.date: 09/29/2021
8-
ms.author: sidandrews
910
ms.topic: troubleshooting
10-
ms.reviewer: mjbrown
11+
ms.date: 02/27/2023
1112
ms.custom: devx-track-dotnet, ignite-2022
1213
---
1314

14-
# Diagnose and troubleshoot Azure Cosmos DB "Request header too large" message
15+
# Diagnose and troubleshoot "request header too large" or "bad request" messages in Azure Cosmos DB SDK for .NET
16+
1517
[!INCLUDE[NoSQL](../includes/appliesto-nosql.md)]
1618

17-
The "Request header too large" message is thrown with an HTTP error code 400. This error occurs if the size of the request header has grown so large that it exceeds the maximum-allowed size. We recommend that you use the latest version of the SDK. Use at least version 3.x or 2.x, because these versions add header size tracing to the exception message.
19+
The "Request header too large" message is thrown with an HTTP error code 400. This error occurs if the size of the request header has grown so large that it exceeds the maximum-allowed size. We recommend that you use the latest version of the Azure Cosmos DB SDK for .NET. We recommend that you use version 3.x because this major version adds header size tracing to the exception message.
1820

1921
## Troubleshooting steps
22+
2023
The "Request header too large" message occurs if the session or the continuation token is too large. The following sections describe the cause of the issue and its solution in each category.
2124

2225
### Session token is too large
2326

24-
#### Cause:
27+
This section reviews scenarios where the session token is too large.
28+
29+
#### Cause
30+
2531
A 400 bad request most likely occurs because the session token is too large. If the following statements are true, the session token is too large:
2632

2733
* The error occurs on point operations like create, read, and update where there isn't a continuation token.
2834
* The exception started without making any changes to the application. The session token grows as the number of partitions increases in the container. The number of partitions increases as the amount of data increases or if the throughput is increased.
2935

30-
#### Temporary mitigation:
31-
Restart your client application to reset all the session tokens. Eventually, the session token will grow back to the previous size that caused the issue. To avoid this issue completely, use the solution in the next section.
36+
#### Temporary mitigation
37+
38+
Restart your client application to reset all the session tokens. Eventually, the session token grows back to the previous size that caused the issue. To avoid this issue completely, use the solution in the next section.
39+
40+
#### Solution
3241

33-
#### Solution:
3442
> [!IMPORTANT]
3543
> Upgrade to at least .NET [v3.20.1](https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/changelog.md) or [v2.16.1](https://github.com/Azure/azure-cosmos-dotnet-v2/blob/master/changelog.md). These minor versions contain optimizations to reduce the session token size to prevent the header from growing and hitting the size limit.
44+
3645
1. Follow the guidance in the [.NET v3](performance-tips-dotnet-sdk-v3.md) or [.NET v2](performance-tips.md) performance tips articles. Convert the application to use the direct connection mode with the Transmission Control Protocol (TCP). The direct connection mode with the TCP protocol doesn't have the header size restriction like the HTTP protocol, so it avoids this issue. Make sure to use the latest version of the SDK, which has a fix for query operations when the service interop isn't available.
3746
1. If the direct connection mode with the TCP protocol isn't an option for your workload, mitigate it by changing the [client consistency level](how-to-manage-consistency.md). The session token is only used for session consistency, which is the default consistency level for Azure Cosmos DB. Other consistency levels don't use the session token.
3847

3948
### Continuation token is too large
4049

41-
#### Cause:
42-
The 400 bad request occurs on query operations where the continuation token is used if the continuation token has grown too large or if different queries have different continuation token sizes.
43-
44-
#### Solution:
45-
1. Follow the guidance in the [.NET v3](performance-tips-dotnet-sdk-v3.md) or [.NET v2](performance-tips.md) performance tips articles. Convert the application to use the direct connection mode with the TCP protocol. The direct connection mode with the TCP protocol doesn't have the header size restriction like the HTTP protocol, so it avoids this issue.
50+
This section reviews scenarios where the continuation token is too large.
51+
52+
#### Cause
53+
54+
The 400 bad request occurs on query operations where the continuation token is used if the token has grown too large. This error can also occur if different queries have different continuation token sizes.
55+
56+
#### Solution
57+
58+
1. Follow the guidance in the [.NET v3](performance-tips-dotnet-sdk-v3.md) or [.NET v2](performance-tips.md) performance tips articles. Convert the application to use the direct connection mode with the TCP protocol. The direct connection mode with the TCP protocol doesn't have the header size restriction like the HTTP protocol, so it avoids this issue.
4659
1. If the direct connection mode with the TCP protocol isn't an option for your workload, set the `ResponseContinuationTokenLimitInKb` option. You can find this option in `FeedOptions` in v2 or `QueryRequestOptions` in v3.
4760

4861
## Next steps
62+
4963
* [Diagnose and troubleshoot](troubleshoot-dotnet-sdk.md) issues when you use the Azure Cosmos DB .NET SDK.
5064
* Learn about performance guidelines for [.NET v3](performance-tips-dotnet-sdk-v3.md) and [.NET v2](performance-tips.md).

0 commit comments

Comments
 (0)