MQTT Restart on Connection Loss #5659
Unanswered
espruino-discuss
asked this question in
ESP8266
Replies: 1 comment
-
Posted at 2017-04-12 by Wilberforce you need to watch for wifi.on("connected") events - and in this function do your MQTT setup. So if the connection is dropped, or the board restarts, it will then run this code. There is some discussion on gitter about this - you might ask them to post their code so you can see how they have set it up... https://gitter.im/espruino/Espruino?at=58ee1f738e4b63533dbfad9e Something like:
|
Beta Was this translation helpful? Give feedback.
0 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.
-
Posted at 2017-04-12 by Scargill
Using the ESP8266 I've managed a connection - no problem - and an MQTT (https://www.espruino.com/MQTT) connect - with subscribe. All works swimmingly well.
But, if you disconnect and reconnect the router, you've lost your MQTT connection and subscribes - although the WIFI does seem to reconnect automatically.
Has anyone already written something to check for broken MQTT connect - and reconnect automatically? (without which of course it isn't a lot of use :-) )
Beta Was this translation helpful? Give feedback.
All reactions