diff --git a/projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs b/projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs index 817bf0101..788ef088a 100644 --- a/projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs +++ b/projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs @@ -292,6 +292,20 @@ public async ValueTask DisposeAsync() return; } + try + { +#if NETSTANDARD2_0 + _recoveryCancellationTokenSource.Cancel(); +#else + await _recoveryCancellationTokenSource.CancelAsync() + .ConfigureAwait(false); +#endif + } + catch + { + // Ensure dispose does not throw any exceptions. + } + try { await _innerConnection.DisposeAsync()