diff --git a/server/client.go b/server/client.go index b55d467c432..ce9edb57811 100644 --- a/server/client.go +++ b/server/client.go @@ -1307,8 +1307,10 @@ func (c *client) readLoop(pre []byte) { c.mu.Lock() // Activity based on interest changes or data/msgs. + // Also update last receive activity for ping sender if c.in.msgs > 0 || c.in.subs > 0 { c.last = last + c.ping.last = last } if n >= cap(b) { @@ -4568,10 +4570,10 @@ func (c *client) processPingTimer() { if c.kind == ROUTER || c.kind == GATEWAY || c.isSpokeLeafNode() { sendPing = true } else { - // If we received a ping from the other side within the PingInterval then - // there is no need to send a ping. + // If we received client data or a ping from the other side within the PingInterval, + // then there is no need to send a ping. if delta := now.Sub(c.ping.last); delta < pingInterval && !needRTT { - c.Debugf("Delaying PING due to remote ping %v ago", delta.Round(time.Second)) + c.Debugf("Delaying PING due to remote client data or ping %v ago", delta.Round(time.Second)) } else { sendPing = true }