fix: 重连成功后重置 outstandingPings 计数器,修复频繁重连问题
This commit is contained in:
@@ -356,6 +356,10 @@ class ConnectionHandler: ChannelInboundHandler {
|
||||
guard let channel = self.channel else {
|
||||
throw NatsError.ClientError.internalError("empty channel")
|
||||
}
|
||||
|
||||
// 重连成功后重置 ping 计数器,避免累积的失败计数导致立即断开
|
||||
self.outstandingPings.store(0, ordering: .relaxed)
|
||||
|
||||
// Schedule the task to send a PING periodically
|
||||
let pingInterval = TimeAmount.nanoseconds(Int64(self.pingInterval * 1_000_000_000))
|
||||
self.pingTask = channel.eventLoop.scheduleRepeatedTask(
|
||||
|
||||
Reference in New Issue
Block a user