fix: move stale connection stat increments to detection site in RunPingTimerAsync
This commit is contained in:
@@ -642,6 +642,8 @@ public sealed class NatsClient : IDisposable
|
||||
if (Volatile.Read(ref _pingsOut) + 1 > _options.MaxPingsOut)
|
||||
{
|
||||
_logger.LogDebug("Client {ClientId} stale connection -- closing", Id);
|
||||
Interlocked.Increment(ref _serverStats.StaleConnections);
|
||||
Interlocked.Increment(ref _serverStats.StaleConnectionClients);
|
||||
await SendErrAndCloseAsync(NatsProtocol.ErrStaleConnection, ClientClosedReason.StaleConnection);
|
||||
return;
|
||||
}
|
||||
@@ -682,12 +684,6 @@ public sealed class NatsClient : IDisposable
|
||||
break;
|
||||
}
|
||||
|
||||
if (reason == ClientClosedReason.StaleConnection)
|
||||
{
|
||||
Interlocked.Increment(ref _serverStats.StaleConnections);
|
||||
Interlocked.Increment(ref _serverStats.StaleConnectionClients);
|
||||
}
|
||||
|
||||
_logger.LogDebug("Client {ClientId} connection closed: {CloseReason}", Id, reason);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user