Skip to content

Commit eb640c5

Browse files
Copilotjsquire
andcommitted
Address review comments: improve retry info, fix headers, add WebSockets suggestion, and clean up formatting
Co-authored-by: jsquire <[email protected]>
1 parent 5e40d73 commit eb640c5

File tree

1 file changed

+33
-40
lines changed

1 file changed

+33
-40
lines changed

sdk/servicebus/azure-servicebus/TROUBLESHOOTING.md

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ This troubleshooting guide contains instructions to diagnose frequently encounte
77
* [General troubleshooting](#general-troubleshooting)
88
* [Enable client logging](#enable-client-logging)
99
* [Common exceptions](#common-exceptions)
10-
* [Authentication Exceptions](#authentication-exceptions)
11-
* [Connection and Timeout Exceptions](#connection-and-timeout-exceptions)
12-
* [Message and Session Handling Exceptions](#message-and-session-handling-exceptions)
13-
* [Service and Entity Exceptions](#service-and-entity-exceptions)
14-
* [Auto Lock Renewal Exceptions](#auto-lock-renewal-exceptions)
10+
* [Authentication exceptions](#authentication-exceptions)
11+
* [Connection and timeout exceptions](#connection-and-timeout-exceptions)
12+
* [Message and session handling exceptions](#message-and-session-handling-exceptions)
13+
* [Service and entity exceptions](#service-and-entity-exceptions)
14+
* [Auto lock renewal exceptions](#auto-lock-renewal-exceptions)
1515
* [Threading and concurrency issues](#threading-and-concurrency-issues)
1616
* [Thread safety limitations](#thread-safety-limitations)
17-
* [Troubleshooting Authentication issues](#troubleshooting-authentication-issues)
18-
* [Troubleshooting Connectivity issues](#troubleshooting-connectivity-issues)
17+
* [Troubleshooting authentication and authorization issues](#troubleshooting-authentication-and-authorization-issues)
18+
* [Troubleshooting connectivity issues](#troubleshooting-connectivity-issues)
1919
* [Timeout when connecting to service](#timeout-when-connecting-to-service)
2020
* [SSL handshake failures](#ssl-handshake-failures)
2121
* [Adding components to the connection string does not work](#adding-components-to-the-connection-string-does-not-work)
22-
* ["TransportType.AmqpOverWebSocket" Alternative](#transporttypeamqpoverwebsocket-alternative)
23-
* [Azure Identity Authentication Alternative](#azure-identity-authentication-alternative)
22+
* [Specifying AMQP over websockets](#specifying-amqp-over-websockets)
23+
* [Using Service Bus with Azure Identity](#using-service-bus-with-azure-identity)
2424
* [Troubleshooting message handling issues](#troubleshooting-message-handling-issues)
2525
* [Message and session lock issues](#message-and-session-lock-issues)
2626
* [Message size issues](#message-size-issues)
@@ -30,7 +30,6 @@ This troubleshooting guide contains instructions to diagnose frequently encounte
3030
* [Dead letter queue issues](#dead-letter-queue-issues)
3131
* [Quotas](#quotas)
3232
* [Entity not found errors](#entity-not-found-errors)
33-
* [Troubleshooting async operations](#troubleshooting-async-operations)
3433
* [Get additional help](#get-additional-help)
3534
* [Filing GitHub issues](#filing-github-issues)
3635

@@ -77,25 +76,25 @@ ServiceBusErrors often have an underlying AMQP error code which specifies whethe
7776
* `retry_mode`: The delay behavior between retry attempts. Supported values are 'fixed' or 'exponential'
7877
When an exception is surfaced to the application, either all retries were applied unsuccessfully, or the exception was considered non-transient.
7978

80-
#### Authentication Exceptions
79+
#### Authentication exceptions
8180

8281
- **ServiceBusAuthenticationError:** An error occurred when authenticating the connection to the service. This may have been caused by the credentials being incorrect. It is recommended to check the credentials.
8382

84-
- **ServiceBusAuthorizationError:** An error occurred when authorizing the connection to the service. This may have been caused by the credentials not having the right permission to perform the operation. It is recommended to check the permission of the credentials.
83+
- **ServiceBusAuthorizationError:** An error occurred when authorizing the connection to the service. This may have been caused by the credentials not having the right permission to perform the operation, or could be transient due to clock skew or service issues. The client will retry these errors automatically. If you continue to see this exception, it means all configured retries were exhausted - check the permission of the credentials and consider adjusting retry configuration.
8584

8685
See the [Troubleshooting Authentication issues](#troubleshooting-authentication-issues) section to troubleshoot authentication/permission issues.
8786

88-
#### Connection and Timeout Exceptions
87+
#### Connection and timeout exceptions
8988

90-
- **ServiceBusConnectionError:** An error occurred in the connection to the service. This may have been caused by a transient network issue or service problem. It is recommended to retry.
89+
- **ServiceBusConnectionError:** An error occurred in the connection to the service. This may have been caused by a transient network issue or service problem. The client automatically retries these errors - if you see this exception, all configured retries were exhausted. Consider adjusting retry configuration rather than implementing additional retry logic.
9190

92-
- **OperationTimeoutError:** This indicates that the service did not respond to an operation within the expected amount of time. This may have been caused by a transient network issue or service problem. The service may or may not have successfully completed the request; the status is not known. It is recommended to attempt to verify the current state and retry if necessary.
91+
- **OperationTimeoutError:** This indicates that the service did not respond to an operation within the expected amount of time. This may have been caused by a transient network issue or service problem. The service may or may not have successfully completed the request; the status is not known. The client automatically retries these errors - if you see this exception, all configured retries were exhausted. Consider verifying the current state and adjusting retry configuration if necessary.
9392

94-
- **ServiceBusCommunicationError:** Client isn't able to establish a connection to Service Bus. Make sure the supplied host name is correct and the host is reachable. If your code runs in an environment with a firewall/proxy, ensure that the traffic to the Service Bus domain/IP address and ports isn't blocked. For details on which ports need to be open, see the [Azure Service Bus FAQ: What ports do I need to open on the firewall?](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-faq#what-ports-do-i-need-to-open-on-the-firewall--).
93+
- **ServiceBusCommunicationError:** Client isn't able to establish a connection to Service Bus. Make sure the supplied host name is correct and the host is reachable. If your code runs in an environment with a firewall/proxy, ensure that the traffic to the Service Bus domain/IP address and ports isn't blocked. For details on which ports need to be open, see the [Azure Service Bus FAQ: What ports do I need to open on the firewall?](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-faq#what-ports-do-i-need-to-open-on-the-firewall--). You can also try setting the WebSockets transport type (`TransportType.AmqpOverWebsocket`) which often works around port/firewall issues.
9594

9695
See the [Troubleshooting Connectivity issues](#troubleshooting-connectivity-issues) section to troubleshoot connection and timeout issues. More information on AMQP errors in Azure Service Bus can be found [here](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-amqp-troubleshoot).
9796

98-
#### Message and Session Handling Exceptions
97+
#### Message and session handling exceptions
9998

10099
- **MessageSizeExceededError:** This indicates that the max message size has been exceeded. The message size includes the body of the message, as well as any associated metadata and system overhead. The best approach for resolving this error is to reduce the number of messages being sent in a batch or the size of the body included in the message. Because size limits are subject to change, please refer to [Service Bus quotas](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-quotas) for specifics.
101100

@@ -111,17 +110,17 @@ See the [Troubleshooting Connectivity issues](#troubleshooting-connectivity-issu
111110

112111
See the [Troubleshooting message handling issues](#troubleshooting-message-handling-issues) section to troubleshoot message and session lock issues.
113112

114-
#### Service and Entity Exceptions
113+
#### Service and entity exceptions
115114

116115
- **ServiceBusQuotaExceededError:** This typically indicates that there are too many active receive operations for a single entity. In order to avoid this error, reduce the number of potential concurrent receives. You can use batch receives to attempt to receive multiple messages per receive request. Please see [Service Bus quotas](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-quotas) for more information.
117116

118-
- **ServiceBusServerBusyError:** Service isn't able to process the request at this time. Client can wait for a period of time, then retry the operation.
117+
- **ServiceBusServerBusyError:** Service isn't able to process the request at this time. Client can wait for a period of time, then retry the operation. For more information about quotas and limits, see [Service Bus quotas](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-quotas).
119118

120119
- **MessagingEntityNotFoundError:** Entity associated with the operation doesn't exist or it has been deleted. Please make sure the entity exists.
121120

122121
- **MessagingEntityDisabledError:** Request for a runtime operation on a disabled entity. Please activate the entity.
123122

124-
#### Auto Lock Renewal Exceptions
123+
#### Auto lock renewal exceptions
125124

126125
- **AutoLockRenewFailed:** An attempt to renew a lock on a message or session in the background has failed. This could happen when the receiver used by `AutoLockRenewer` is closed or the lock of the renewable has expired. It is recommended to re-register the renewable message or session by receiving the message or connect to the sessionful entity again.
127126

@@ -133,7 +132,7 @@ See the [Troubleshooting message handling issues](#troubleshooting-message-handl
133132

134133
### Thread safety limitations
135134

136-
**Important:** We do not guarantee that the ServiceBusClient, ServiceBusSender, and ServiceBusReceiver are thread-safe or coroutine-safe. We do not recommend reusing these instances across threads or sharing them between coroutines.
135+
**Important:** We do not guarantee that the `ServiceBusClient`, `ServiceBusSender`, and `ServiceBusReceiver` are thread-safe or coroutine-safe. We do not recommend reusing these instances across threads or sharing them between coroutines.
137136

138137
The data model type, `ServiceBusMessageBatch` is not thread-safe or coroutine-safe. It should not be shared across threads nor used concurrently with client methods.
139138

@@ -174,7 +173,9 @@ async with client:
174173
await asyncio.gather(*(send_batch(i, sender) for i in range(5)))
175174
```
176175

177-
For scenarios requiring concurrent sending from multiple threads, ensure proper thread-safety management using mechanisms like threading.Lock(). **Note:** Native async APIs should be used instead of running in a ThreadPoolExecutor, if possible.
176+
For scenarios requiring concurrent sending from multiple threads, ensure proper thread-safety management using mechanisms like `threading.Lock()`.
177+
178+
> **NOTE:** Native async APIs should be used instead of running in a `ThreadPoolExecutor`, if possible.
178179
179180
```python
180181
import threading
@@ -204,7 +205,7 @@ with client:
204205
executor.submit(send_batch, i, sender)
205206
```
206207

207-
## Troubleshooting Authentication issues
208+
## Troubleshooting authentication and authorization issues
208209

209210
Authentication errors typically occur when the credentials provided are incorrect or have expired. Authorization errors occur when the authenticated identity doesn't have sufficient permissions.
210211

@@ -216,7 +217,7 @@ The following verification steps are recommended, depending on the type of autho
216217

217218
- [Verify the correct RBAC roles were granted](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-managed-service-identity) - Indicated by errors: `Send/Listen claim(s) are required to perform this operation.` In this case, ensure that the appropriate roles were assigned: `Azure Service Bus Data Owner`, `Azure Service Bus Data Sender`, or `Azure Service Bus Data Receiver`.
218219

219-
## Troubleshooting Connectivity issues
220+
## Troubleshooting connectivity issues
220221

221222
### Timeout when connecting to service
222223

@@ -236,19 +237,19 @@ To troubleshoot:
236237

237238
### SSL handshake failures
238239

239-
This error can occur when an intercepting proxy is used. To verify, it is recommended that the application be tested in the host environment with the proxy disabled.
240+
This error can occur when an intercepting proxy is used. To verify, it is recommended that the application be tested in the host environment with the proxy disabled. Note that intercepting proxies are not a supported scenario.
240241

241242
### Adding components to the connection string does not work
242243

243244
The current generation of the Service Bus client library supports connection strings only in the form published by the Azure portal. These are intended to provide basic location and shared key information only; configuring behavior of the clients is done through its options.
244245

245246
Previous generations of the Service Bus clients allowed for some behavior to be configured by adding key/value components to a connection string. These components are no longer recognized and have no effect on client behavior.
246247

247-
#### "TransportType.AmqpOverWebSocket" Alternative
248+
#### Specifying AMQP over websockets
248249

249250
To configure web socket use, pass the [`transport_type=TransportType.AmqpOverWebsocket`](https://learn.microsoft.com/python/api/azure-servicebus/azure.servicebus.transporttype?view=azure-python) to the ServiceBusClient.
250251

251-
#### Azure Identity Authentication Alternative
252+
#### Using Service Bus with Azure Identity
252253

253254
To authenticate with Azure Identity, see: [Client Identity Authentication](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/servicebus/azure-servicebus/samples/sync_samples/client_identity_authentication.py).
254255

@@ -262,9 +263,9 @@ Messages, sessionful and non-sessionful, in Service Bus have a lock duration dur
262263

263264
**MessageLockLostError and SessionLockLostError resolution:**
264265
1. Process messages faster or increase lock duration
265-
2. If setting `prefetch_count` to a large number, consider setting it lower as it can cause message lock expiration if processing takes too long. The client cannot extend locks for prefetched messages.
266+
2. If setting `prefetch_count` to a large number, consider setting it lower as the lock timer starts running when the message is fetched, even though not visible to the application and the client cannot extend locks for prefetched messages.
266267
3. Use `AutoLockRenewer` for long-running processing.
267-
* When running the async AutoLockRenewer, ensure that the event loop is not blocked during message processing. (e.g. `time.sleep(60)` --> `await asyncio.sleep(60)`). Otherwise, the AutoLockRenewer will be prevented from running in the background.
268+
* When running the async `AutoLockRenewer`, ensure that the event loop is not blocked during message processing. (e.g. `time.sleep(60)` --> `await asyncio.sleep(60)`). Otherwise, the `AutoLockRenewer` will be prevented from running in the background.
268269

269270
```python
270271
from azure.servicebus import AutoLockRenewer
@@ -284,12 +285,7 @@ with receiver:
284285
1. Reduce message payload size
285286
2. Consider splitting large messages across multiple smaller messages
286287

287-
**Service Bus message size limits:**
288-
- Standard tier: 256 KB per message
289-
- Premium tier: 1 MB per message
290-
291-
For the most up-to-date information on Service Bus limits, refer to the [Azure Service Bus quotas and limits](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-quotas) documentation.
292-
288+
For the most up-to-date information on Service Bus message size limits, refer to the [Azure Service Bus quotas and limits](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-quotas) documentation.
293289

294290
## Troubleshooting receiver issues
295291

@@ -299,7 +295,7 @@ When attempting to receive multiple messages using `receive_messages()` with `ma
299295

300296
**Why this happens:**
301297
- Service Bus optimizes for throughput and latency
302-
- After the first message is received, the receiver waits only a short time (typically 20ms) for additional messages
298+
- After the first message is received, the receiver prioritizes processing it and does not attempt to build a batch of the requested size
303299
- The `max_wait_time` controls how long to wait for the **first** message, not subsequent ones
304300

305301
**Resolution:**
@@ -362,7 +358,7 @@ def continuous_message_processing(receiver):
362358

363359
### Mixing sync and async code
364360

365-
Mixing synchronous and asynchronous Service Bus operations can cause issues such as async operations, such as the `AutoLockRenewer`, hanging indefinitely due to the event loop being blocked. Ensure that blocking calls are not made when receiving and message processing.
361+
Mixing synchronous and asynchronous Service Bus operations can cause issues such as the `AutoLockRenewer` hanging indefinitely because the event loop is blocked. Ensure that blocking calls are not made when receiving and processing messages asynchronously.
366362

367363
### Dead letter queue issues
368364

@@ -389,7 +385,6 @@ with dlq_receiver:
389385
print(f"Dead letter description: {message.dead_letter_error_description}")
390386
```
391387

392-
393388
## Quotas
394389

395390
Information about Service Bus quotas can be found [here](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-quotas).
@@ -402,8 +397,6 @@ Information about Service Bus quotas can be found [here](https://learn.microsoft
402397
3. Check if the entity was deleted and needs to be recreated
403398
4. Verify you're connecting to the correct namespace
404399

405-
## Troubleshooting async operations
406-
407400
## Get additional help
408401

409402
Additional information on ways to reach out for support can be found in the [SUPPORT.md](https://github.com/Azure/azure-sdk-for-python/blob/main/SUPPORT.md) at the root of the repo.

0 commit comments

Comments
 (0)