Need help understand the source of User Errors seen in Insights of Azure Service Bus

Mathieu Masciotra 20 Reputation points
2025-02-20T13:21:26.59+00:00

Hi,

I'm seeing a lot of User Errors on the Insights section of Azure Service Bus. Looking at logs in the service using the following query:

AzureDiagnostics
| where ResourceProvider == "MICROSOFT.SERVICEBUS"
| where ErrorMessage_s != ""

I see some errors that make sense, like the service is being throttled, but I also see a lot of errors that I don't understand. For example:

  • br0012cannot create the session receiver because the entity <namespace>:queue:<queuename> is not open.
  • brokeredmessage has been disposed. sequencenumber:361043
  • cannot access a disposed object. object name: 'microsoft.cloud.servicebus.messaging.amqp.amqpnodeconnectionmanager+connectionpoolmanager'.
  • cannot access a disposed object. object name: 'microsoft.applicationserver.messaging.broker.containersessionreceiver'.

Would it be possible to get explanation on these and how to fix them?

Thank you

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
669 questions
0 comments No comments
{count} votes

Accepted answer
  1. Khadeer Ali 3,750 Reputation points Microsoft Vendor
    2025-02-20T14:43:44.92+00:00

    @Mathieu Masciotra ,

    Thanks for reaching out .I understand that you're encountering several user errors in the Insights section of Azure Service Bus. Let's go through each of the errors you've mentioned and see how we can address them:

    br0012: Cannot create the session receiver because the entity <namespace>:queue:<queuename> is not open.

    Causes:

    This error usually indicates a timing issue. Your code may be trying to create a session receiver before the queue or namespace is fully initialized or available. This can occur during:

    • Application startup
    • Failover scenarios
    • Temporary network issues

    Fix:

    • Implement retry logic with exponential backoff (e.g., retry after 1s, 2s, 4s, etc.).
    • Before creating the receiver, check the queue status using Azure management libraries to ensure it's active.
    • If this happens at startup, ensure that the Service Bus client is initialized before attempting to create the receiver.

    brokeredmessage has been disposed. sequencenumber:361043

    Causes:

    This occurs when your code tries to access a message that has already been completed, abandoned, or expired. It can also happen if:

    • The message is prefetched but not processed in time.
    • The message processing logic does not correctly handle multiple consumers.

    Fix:

    • Ensure that message processing is idempotent, meaning reprocessing a message should not have unintended side effects.
    • Use the message ID to track processed messages.
    • If messages time out, consider increasing the message lock duration (but use caution to avoid unnecessary delays).
    • Check your code to ensure messages are completed, abandoned, or deferred properly, avoiding duplicate actions.

    Cannot access a disposed object. object name: 'microsoft.cloud.servicebus.messaging.amqp.amqpnodeconnectionmanager+connectionpoolmanager'.

    Causes:

    This happens when a connection to Azure Service Bus is closed before it can be used. Possible reasons include:

    • Frequent connection opening and closing instead of reusing a single instance.
    • Network instability causing unexpected disconnections.
    • Connection pooling issues in the Service Bus SDK.

    Fix:

    • Use a single instance of ServiceBusClient across your application instead of creating new instances frequently.
    • If you're using C#, avoid using using statements for ServiceBusClient; instead, create a long-lived instance.
    • Enable connection pooling where possible.
    • Ensure you're using the latest version of the Azure Service Bus SDK to benefit from bug fixes and performance improvements.

    cannot access a disposed object. object name: 'microsoft.applicationserver.messaging.broker.containersessionreceiver'.

    Causes:

    This is similar to the previous error but specific to session receivers. It occurs when a session receiver is closed too early while messages are still being processed.

    Fix:

    • Ensure that session receivers stay open until all messages in the session have been processed.
    • Avoid prematurely closing the session receiver.
    • Implement retry logic to recreate the session receiver if a disconnection occurs.

    These errors are often transient and can be mitigated with proper retry logic, connection management, and ensuring message processing is handled efficiently. If the issues persist, enabling detailed logging and using Azure Monitor can help diagnose underlying causes.

    Hope this helps. Do let us know if you have any further queries.


    If this answers your query, do click Accept Answer and Yes for "Was this answer helpful." And if you have any further questions, let us know.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.