Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/NATS.Client.Core/NatsConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,15 +756,11 @@ private async void ReconnectLoop()
// which in turn would crash the application.
// (e.g. we've seen this with EventLog provider on Windows)
}

return;
}

// the reconnect loop should never get here, since everything
// is either an early return or stays in the loop
try
{
_logger.LogError(NatsLogEvents.Connection, "Retry loop stopped and connection state is invalid [{ReconnectCount}]", reconnectCount);

@mtmk mtmk May 1, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is logged on a clean reconnect which isn't an error case

_logger.LogDebug(NatsLogEvents.Connection, "Reconnect loop stopped [{ReconnectCount}]", reconnectCount);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helpful for debugging reconnect issues

}
catch
{
Expand Down Expand Up @@ -946,6 +942,10 @@ private async void StartPingTimer(CancellationToken cancellationToken)
await periodicTimer.WaitForNextTickAsync(cancellationToken).ConfigureAwait(false);
}
}
catch (OperationCanceledException)
{
// Cancelling is part of a normal reconnect operation, so we don't need to log this
}
catch (Exception e)
{
if (!IsDisposed)
Expand Down