I'm testing against test.mosquitto.org. Every so often I get disconnected - which I imagine is from the server and is to be expected, as I think they regularly rollout the latest version.
I have a disconnect event I can listen on, and currently I reissue mqtt.connect() in the events callback. My problem with this approach is that I'm losing memory. It might survive one reconnect, but not two. I have duplicated message listeners which I imagine is part of the memory problem.
I considered another approach would be to save to memory and fire the reset() function, to bring the board and whole program back up?
But is there any pattern/approach that I could use to recover without a restart?
Edit: I've just considered that maybe I should unbind the listeners in the disconnect event callback too?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'm testing against
test.mosquitto.org
. Every so often I get disconnected - which I imagine is from the server and is to be expected, as I think they regularly rollout the latest version.I have a
disconnect
event I can listen on, and currently I reissuemqtt.connect()
in the events callback. My problem with this approach is that I'm losing memory. It might survive one reconnect, but not two. I have duplicated message listeners which I imagine is part of the memory problem.I considered another approach would be to save to memory and fire the
reset()
function, to bring the board and whole program back up?But is there any pattern/approach that I could use to recover without a restart?
Edit: I've just considered that maybe I should unbind the listeners in the disconnect event callback too?