fix: 重连成功后重置 outstandingPings 计数器,修复频繁重连问题

This commit is contained in:
wenzuhuai
2026-01-23 09:58:40 +08:00
parent 30fb5d8b27
commit ec4618db87

View File

@@ -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(