Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectDisposedException when connection is closed from the server #1760

Open
lukebakken opened this issue Jan 7, 2025 · 0 comments
Open
Assignees
Labels
Milestone

Comments

@lukebakken
Copy link
Contributor

lukebakken commented Jan 7, 2025

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.

https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/v7.0.0/projects/RabbitMQ.Client/Impl/MainSession.cs

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

  1. Use MassTransit.RabbitMQ 8.3.4
  2. Log FirstChanceException
  3. Create a consumer and connect to the broker
  4. Close the connections on the broker
  5. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant