Skip to content

disabling AutoReconnect causes spurious error to be logged #697

@rittneje

Description

@rittneje

We set AutoReconnect to false in our ClientOptions. When the connection to the broker is lost unexpectedly, we see the following error come from this library:

[client] BUG BUG BUG reconnection function is nil

Tracing through the code, this is because disDone is assigned like so.

disDone, err := c.status.ConnectionLost(c.options.AutoReconnect && c.status.ConnectionStatus() > connecting)

Since c.options.AutoReconnect is false, that will pass false to c.status.ConnectionLost. Thus the callback that it returns will itself return nil, nil.

paho.mqtt.golang/status.go

Lines 278 to 280 in 714f7c0

if !reconnectRequested || !proceed {
return nil, nil
}

This in turn triggers the log that "should never happen".

paho.mqtt.golang/client.go

Lines 547 to 552 in 714f7c0

reConnDone, err := disDone(true)
if err != nil {
ERROR.Println(CLI, "failure whilst reporting completion of disconnect", err)
} else if reConnDone == nil { // Should never happen
ERROR.Println(CLI, "BUG BUG BUG reconnection function is nil", err)
}

I believe this regression was introduced in v1.4.2. It prevents us from upgrading from v1.3.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions