Open rittneje opened 3 days ago
I've assumed it's harmless.
The library has quite a few options and I was concerned that I may have missed some possible combinations when rearchitecting the status handling (it was a bit of a mess), hence the "BUG BUG" log entry. Have had a quick look and the log entry should be supressed if c.options.AutoReconnect == false
(probably best to add something like reconnectExpected := c.options.AutoReconnect && c.status.ConnectionStatus() > connecting
at the top, and then use that value).
Having said that the code looks like it will work OK, it's just an incorrect log entry. Will fix when I get a chance (or would welcome a PR).
We set
AutoReconnect
to false in ourClientOptions
. When the connection to the broker is lost unexpectedly, we see the following error come from this library:Tracing through the code, this is because
disDone
is assigned like so. https://github.com/eclipse-paho/paho.mqtt.golang/blob/714f7c0231294ec4144f0e0e5fc5b43a6d430d2f/client.go#L517Since
c.options.AutoReconnect
is false, that will pass false toc.status.ConnectionLost
. Thus the callback that it returns will itself returnnil, nil
. https://github.com/eclipse-paho/paho.mqtt.golang/blob/714f7c0231294ec4144f0e0e5fc5b43a6d430d2f/status.go#L278-L280This in turn triggers the log that "should never happen". https://github.com/eclipse-paho/paho.mqtt.golang/blob/714f7c0231294ec4144f0e0e5fc5b43a6d430d2f/client.go#L547-L552
I believe this regression was introduced in v1.4.2. It prevents us from upgrading from v1.3.5.