-
Notifications
You must be signed in to change notification settings - Fork 613
Description
Describe the bug
Logging FirstChanceExceptions shows some strange ObjectDisposedException:
https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/v7.0.0/projects/RabbitMQ.Client/Impl/Connection.Heartbeat.cs#L164 accessing .Token
here can result in an ObjectDisposedException. That is catched, but the comment states that its for the timer
The SetSessionClosingAsync uses a _closingSemaphore
that can already be disposed. It seems this isn't gracefully handled in the stacktrace.
I'm not sure if this is causing issues but looking at the code it might be needed that these code paths all need to have exception handling to prevent code not to terminate if these ObjectDisposedExceptions are to be expected.
Reproduction steps
- Use MassTransit.RabbitMQ 8.3.4
- Log FirstChanceException
- Create a consumer and connect to the broker
- Close the connections on the broker
- Observe the consumer trying to reconnect
Do this a couple of times and you'll see the related exception
Expected behavior
gracefully handle ObjectDisposedException on all code paths for closed connections
Additional context
Originally reported by @ramonsmits here: #1749