Skip to content

Commit

Permalink
Merge pull request #238 from ChIoT-Tech/master
Browse files Browse the repository at this point in the history
Resolve erroneous ping timeout
  • Loading branch information
MattBrittan committed Feb 12, 2024
2 parents 6273f16 + d6b4c52 commit ace27f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion paho/pinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ func (p *DefaultPinger) Run(ctx context.Context, conn net.Conn, keepAlive uint16
continue
}

lastPingSent = time.Now() // set before sending because WriteTo may return after PINGRESP is handled
if _, err := packets.NewControlPacket(packets.PINGREQ).WriteTo(conn); err != nil {
p.debug.Printf("DefaultPinger packet write error: %v", err)
return fmt.Errorf("failed to send PINGREQ: %w", err)
}
lastPingSent = time.Now()
timer.Reset(interval)
}
}
Expand Down

0 comments on commit ace27f7

Please sign in to comment.