Open charles-d-burton opened 6 days ago
Maybe this behavior is expected? If I add another goroutine that has a ticker to ping the server i stop receiving error messages. I also added a client.Disconnect()
if the handler throws an error. That seems to handle the problem of the disconnect not showing up in the system. All of this is an easy enough fix.
io.EOF and net.ErrClosed are special errors. We should always disconnect on receiving them since there is no more data to be expected after receiving them. Changes in #12. Feel free to test :)
I ran into a bug with your
client.HandleNext()
function. When I setup a connection like you have in your examples after about a minuteclient.HandleNext()
starts blasting my terminal with EOF errors. According to the function docs if it has an error it should disconnect and go into a reconnect, but that's not the case. The code in question is:After about a minute it hits that
if err != nil
block and just spins out with EOFComments here indicate that it should fail and try to reconnect
https://github.com/soypat/natiu-mqtt/blob/dc6618a0526531c36907ea4a763f2d85ad4face9/client.go#L56
Here's the full code for reference: