eclipse / paho.golang

Go libraries
Other
327 stars 92 forks source link

Occasional invalid `PINGRESP timed out` (local broker) #237

Closed MattBrittan closed 6 months ago

MattBrittan commented 6 months ago

Describe the bug

Connecting to a local (client and broker in docker containers; host is EC2 VM) broker and seeing occasional disconnections due to PINGRESP timed out.

To reproduce

Don't have a reproducer; however added info to the error (return fmt.Errorf("PINGRESP timed out (%v, %v)", lastPingSent, lastPingResponse)) and got:

ping handler error: PINGRESP timed out (2024-02-11 11:54:04.033683423 +1300 NZDT m=+1.344078227, 2024-02-11 11:54:04.033226938 +1300 NZDT m=+1.343621806)

So the lastPingSent is a fraction of a second after the lastPingResponse

Believe the issue is that the ping response is received pretty much instantly. Moving the lastPingSent = time.Now() above the packets.NewControlPacket(packets.PINGREQ).WriteTo(conn) should solve this (have this running). However this fix would also increase the possibility of timeouts occurring when the connection is highly utilised; so will have a think about better options.

Expected behaviour

Don't really expect timeouts with this setup (could happen very occasionality)

Software used:

thejan2009 commented 6 months ago

Hey, is there any chance this fix could land in a patch release?

MattBrittan commented 6 months ago

Yep - did not know anyone else was seeing the issue.