Replies: 1 comment 9 replies
-
You might like to look at mqtt_as which offers a resilient MQTT solution. |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using MQTT on an ESP32, It serves as a client to a broker running on a Node-Red server. I've found an issue when trying to reconnect the client after the server has gone down, then restarted.
On loss of connection to the server my software first makes sure it's still connected to the network, and re-establishes if necessary.
Next the it recreates a client object and tries to connect. If the TRY connect fails it retries every 15secs.
Here's the issue it will reconnect to the MQTT broker if the server returns during tries 1 thru 9. For the 10th try and beyond, even when the server returns it fails to connect; it just keeps trying not throwing any errors, other than it not being connected. Is there some timeout limiting the number of connection re-tries, or has some data stack overflowed. I've even modified the code to test for network connection, client object creation and client connection each 15 sec interval without success. However, with the server running, if I simply reboot the ESP32 it connects.
Does, anyone have suggestions as to why there seems to be a MQTT client connection TRY limit?
MM
UPDATE: I believe I solved the issue.
In the re-connection loop I printed the OSError codes, thru loop 10 the code was "[Errno 113] ECONNABORTED"; after loop 10 it changed to simply "23". On investigation error 23 refers to too many open sockets. Simply placing a myclient.disconnect() in the loop should correct the problem.
MM
FOLLOW_UP: Unfortunately putting myclient.disconnect() in the loop throws an error. Also, tried myclient.init(); that throws a confusing error saying the attribute "init" doesn't exist, but it is listed as a function for "myclient".
Right now the only solution that works is a machine.reset().
MM
Beta Was this translation helpful? Give feedback.
All reactions