Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gojimmypi opened this issue Nov 9, 2022 · 0 comments
Assignees

Comments

@gojimmypi
Copy link
Contributor

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.

@gojimmypi gojimmypi self-assigned this Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant