Azure / azure-service-bus

☁️ Azure Service Bus service issue tracking and samples
https://azure.microsoft.com/services/service-bus
MIT License
585 stars 781 forks source link

System.ObjectDisposedException #457

Closed dastewa closed 2 years ago

dastewa commented 2 years ago

Description

Actual Behavior

  1. Our service is seeing an System.ObjectDisposedException in our logs every once in a while.

Expected Behavior

  1. No System.ObjectDisposedException bring thrown or appearing in our logs.

Hi team,

I'd like to understand the possible causes of the following exception that I've seen discussed on the archived repo. We see it infrequently in our service logs, but the service bus is otherwise working. Does the service bus client handle this exception and retry the connection?:

{
  "Exception":
    {
      "ClassName": "System.ObjectDisposedException",
      "Message": "Cannot access a disposed object.",
      "Data": null,
      "InnerException": null,
      "HelpURL": null,
      "StackTraceString": "   at Microsoft.Azure.ServiceBus.Core.MessageReceiver.OnReceiveAsync(Int32 maxMessageCount, TimeSpan serverWaitTime)\r\n   at Microsoft.Azure.ServiceBus.Core.MessageReceiver.<>c__DisplayClass65_0.<<ReceiveAsync>b__0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)\r\n   at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)\r\n   at Microsoft.Azure.ServiceBus.Core.MessageReceiver.ReceiveAsync(Int32 maxMessageCount, TimeSpan operationTimeout)\r\n   at Microsoft.Azure.ServiceBus.Core.MessageReceiver.ReceiveAsync(TimeSpan operationTimeout)\r\n   at Microsoft.Azure.ServiceBus.MessageReceivePump.<MessagePumpTaskAsync>b__12_0()",
      "RemoteStackTraceString": null,
      "RemoteStackIndex": 0,
      "ExceptionMethod": null,
      "HResult": -2146232798,
      "Source": "Microsoft.Azure.ServiceBus",
      "WatsonBuckets": null,
      "ObjectName": "$cbs",
    },
  "ExceptionReceivedContext":
    {
      "Action": "Receive",
      "Endpoint": "lagrosb-prod-westeurope.servicebus.windows.net",
      "EntityPath": "goals-and-activities-topic/Subscriptions/goals-service",
      "ClientId": "MessageReceiver3goals-and-activities-topic/Subscriptions/goals-service",
    },
}

Thank you

EldertGrootenboer commented 2 years ago

Depending on the specified retry policy, this will indeed be retried. More information can be found at https://docs.microsoft.com/en-us/azure/architecture/best-practices/retry-service-specific#service-bus.