Skip to content

Reconnect problem: MqttSocket_Connect relies on incorrect client->flags status value #313

@gojimmypi

Description

@gojimmypi

When MqttSocket_Connect is called but the client object loses a previously successful connection to the remote host, the connection logic skips the call to actually reconnect to the host:

rc = client->net->connect(client->net->context, host, port, timeout_ms);

This behavior was observed in an embedded environment (ESP32) connected to a WiFi router. The LinkSys WiFi router itself was connected to another router which during testing which had the WAN/Internet cable removed. See blog. The ETH0 cable was disconnected from Edgerouter to observe the device still "connected" to the local network, but not actually connected to the internet:

image

This problem is likely with the client object not properly setting flag when the device is disconnected from the internet and not just the local network. Specifically, this was observed to return 1 when the WAN network cable was disconnected (but the device itself was still connected to local subnet):

(client->flags & MQTT_CLIENT_FLAG_IS_CONNECTED)

The client->flags could probably be set manually in an end-user callback function, but this library should do that automatically.

This issue is similar to the Automatic connect function #41 feature request.

Further details in progress.

Metadata

Metadata

Assignees

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