You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the above code to connect to a gmqtt server, at the moment I get a connection I disconnect the Internet(I am using mac and disconnect means I close the WIFI connection. And it would take so long (sometime it might take half and two minutes) for the server to detect a disconnection!
You can see that I have set KeepAlive to 30 seconds so this should not happen right?
And by the way, after searching google I found that actually KeepAlive is for a client to send packets to the server and makes sure the connection doesn't break up. So right now I am kind of confused, actually there is a max_keepalive setting in config.yml.
After struggling for days, with the help of gmqtt ownerDrmagicE I finally noticed what went wrong!
It is because of an error lives in a comment from this mqtt repository => paho.mqtt.golang, the bugged comments goes like this and hasn't been fixed for years🤷🏻♂️
// SetKeepAlive will set the amount of time (in seconds) that the client// should wait before sending a PING request to the broker. This will// allow the client to know that a connection has not been lost with the// server.func (o*ClientOptions) SetKeepAlive(k time.Duration) *ClientOptions {
o.KeepAlive=int64(k/time.Second)
returno
}
It says SetKeepAlive will set the amount of time (in seconds) ! No that's wrong! it's not seconds but nanoseconds! There is a big difference!
that is the paho.mqtt.golang client's keepalive setting should be like this:
And it took me days to figure it out.(With the help of gmqtt's main contributor, who is very very generous and kind and smart too!)
Actually there has been an issue raised by another victim of this typo: Docs for SetKeepAlive on connection options are incorrect
OMG this is so poisonous and without DrmagicE's guide I would be mentally tortured for who knows how many more days or weeks!
What version of Gmqtt are you using?
I am using the latest version which is
v0.3.0
What did you do?
Here is the client file I am using to produce this error:
I am using the above code to connect to a gmqtt server, at the moment I get a connection I disconnect the Internet(I am using mac and
disconnect
means I close the WIFI connection. And it would take so long (sometime it might take half and two minutes) for the server to detect a disconnection!You can see that I have set
KeepAlive
to 30 seconds so this should not happen right?And by the way, after searching google I found that actually
KeepAlive
is for a client to send packets to the server and makes sure the connection doesn't break up. So right now I am kind of confused, actually there is a max_keepalive setting inconfig.yml
.And here is my config.yml:
And here is my onBasicAuth hook:
What did you expect to see?
I expect the server to detect a disconnection in 45 seconds or 60 seconds, not minutes.
What did you see instead?
I saw an error but this error occurred so late!
Many thanks
If you go through my issue, I would like to give you a big thank you!🙇🏻♂️
The text was updated successfully, but these errors were encountered: