Skip to content

docs: howto use Disconnect in presence of connection issues? #732

@andig

Description

@andig

I'm working with an MQTT broker that allows only a single connection per user at a time. Currently, connecting is implemented like this:

timeout := 30 * time.Second
if t := paho.Connect(); !t.WaitTimeout(timeout) {
	return errors.New("connect timeout")
} else if err := t.Error(); err != nil {
	return fmt.Errorf("connect: %w", err)
}
defer paho.Disconnect(1000)

From the docs, it's not clear, if a Disconnect is also required in case of the connection timeout in order to clean up any dangling go routines? I wouldn't expect it to be required in case of error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions