Skip to content

Conversation

ramonsmits
Copy link
Member

@ramonsmits ramonsmits commented Jun 22, 2023

  1. ChannelProvider now has a CancellationTokenSource that gets cancelled when it is Disposed to ensure any reconnect while loop to be stopped
  2. Shutdown Handler will teardown and dispose existing channel if it exists.

@ramonsmits ramonsmits changed the base branch from master to release-8.0 June 22, 2023 13:47
@ramonsmits ramonsmits requested a review from bording June 22, 2023 14:39
bording

This comment was marked as resolved.

@ramonsmits ramonsmits changed the base branch from release-8.0 to master July 6, 2023 13:06
@ramonsmits ramonsmits force-pushed the fix-ChannelProvider-reconnect-remaining-active branch from dfa8865 to 1662af1 Compare July 6, 2023 13:12
@ramonsmits

This comment was marked as resolved.

@ramonsmits ramonsmits changed the title Fix channel provider reconnect remaining active Ensure reconnect loop in ChannelProvider terminates when disposed Jul 6, 2023
@ramonsmits
Copy link
Member Author

There is another reconnection loop that needs to be looked at: The one in the message pump. Has that been examined to see if it would have a similar issue?

Yes, that has been examined by @danielmarbach and that already has cancellation support that will ensure the loop will be terminated:

async Task Reconnect(CancellationToken cancellationToken)
{
try
{
while (!cancellationToken.IsCancellationRequested)
{
try
{
if (connection.IsOpen)
{
connection.Close();
}
connection.Dispose();
Logger.InfoFormat("'{0}': Attempting to reconnect in {1} seconds.", name, retryDelay.TotalSeconds);
await Task.Delay(retryDelay, cancellationToken).ConfigureAwait(false);
ConnectToBroker();
break;
}
catch (Exception ex) when (!ex.IsCausedBy(cancellationToken))
{
Logger.InfoFormat("'{0}': Reconnecting to the broker failed: {1}", name, ex);
}
}
Logger.InfoFormat("'{0}': Connection to the broker reestablished successfully.", name);
}
catch (Exception ex) when (ex.IsCausedBy(cancellationToken))
{
Logger.DebugFormat("'{0}': Reconnection canceled since the transport is being stopped: {1}", name, ex);
}
catch (Exception ex)
{
Logger.WarnFormat("'{0}': Unexpected error while reconnecting: '{1}'", name, ex);
}
}

Feels like there are too many changes here that are clouding up the actual fix required, which would be to abort the reconnection loop if the channel provider has been shut down.

You are absolutely right. Removed the "wait for reconnect loop" logic.

@ramonsmits ramonsmits reopened this May 29, 2024
@Particular Particular deleted a comment from github-actions bot May 29, 2024
@Particular Particular deleted a comment from github-actions bot May 29, 2024
@Particular Particular deleted a comment from github-actions bot May 29, 2024
@Particular Particular deleted a comment from github-actions bot May 29, 2024
@Particular Particular deleted a comment from github-actions bot May 29, 2024
@Particular Particular deleted a comment from github-actions bot May 29, 2024
@ramonsmits ramonsmits removed the stale label May 29, 2024
@ramonsmits ramonsmits force-pushed the fix-ChannelProvider-reconnect-remaining-active branch 2 times, most recently from 0560786 to d07f297 Compare June 3, 2024 20:39
@ramonsmits ramonsmits force-pushed the fix-ChannelProvider-reconnect-remaining-active branch from 88b6414 to 594461a Compare June 18, 2024 09:47

This comment was marked as resolved.

@danielmarbach danielmarbach force-pushed the fix-ChannelProvider-reconnect-remaining-active branch from 594461a to 5a67bec Compare July 31, 2024 13:31
@danielmarbach danielmarbach marked this pull request as ready for review July 31, 2024 13:43
@danielmarbach danielmarbach force-pushed the fix-ChannelProvider-reconnect-remaining-active branch from 1995f07 to 435104d Compare July 31, 2024 13:54
@danielmarbach
Copy link
Contributor

Closed in favor of #1435

@danielmarbach danielmarbach deleted the fix-ChannelProvider-reconnect-remaining-active branch August 21, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChannelProvider Publish reconnection attempts continue forever after IEndpointInstance had been stopped

4 participants