-
• #2
This is the console output of my server when the client is trying to reconnect. Any ideas ?
1484814088: mosquitto version 1.4.8 (build date 2017-01-18 17:13:27+0530) starting 1484814088: Config loaded from /etc/mosquitto/mosquitto.conf. 1484814088: Opening ipv4 listen socket on port XXXX. 1484814089: New connection from XXXXXXXXXX on port XXXX. 1484814089: New connection from XXXXXXXXXX on port XXXX. 1484814090: New client connected from XXXXXXXXXX as 5ccf7f84-8675 (c0, k65535, XXXXXXXXXX'). 1484814092: Socket error on client 5ccf7f84-8675, disconnecting. 1484814096: New connection from XXXXXXXXXX on port XXXX. 1484814096: New connection from XXXXXXXXXX on port XXXX. 1484814096: New connection from XXXXXXXXXX on port XXXX. 1484814096: New connection from XXXXXXXXXX on port XXXX. 1484814096: Client 5ccf7f84-8675 disconnected. 1484814096: New client connected from XXXXXXXXXX as 5ccf7f84-8675 (c0, k65535, XXXXXXXXXX'). 1484814096: Socket error on client 5ccf7f84-8675, disconnecting. 1484814100: New connection from XXXXXXXXXX on port XXXX. 1484814100: New connection from XXXXXXXXXX on port XXXX. 1484814101: New connection from XXXXXXXXXX on port XXXX. 1484814101: New connection from XXXXXXXXXX on port XXXX.
-
• #3
OK, I think I figured the problem
a) When it disconnects from the server it throws "disconnected" event twice.
b) When it reconnects it does not fires "connected" event, but still receives messages.Can it be fixed ?
-
• #4
Strange - but yes, the code's here: https://github.com/espruino/EspruinoDocs/blob/master/modules/MQTT.js
If you wanted to create a pull request that fixed it it'd be great!
I'm not sure, but it might also be worth reconnecting after a timeout, rather than straight away? It might help...
-
• #5
I think that's the tinyMQTT module rather than the core MQTT module. It's not behaviour I've seen but but I haven't used it in a long while TBH. A fix/pull request welcome though.
-
• #7
See other thread I responded on. If you're using tinyMQTT from here : https://github.com/olliephillips/tinyMQTT, that's all I have :)
-
• #8
Also, you could try the non-tinyMQTT module and see if that helps? I know I recently fixed the double-disconnect issue there.
-
• #9
Hey @Gordon,
Sorry for the delayed response. I was away for a business trip...
https://github.com/olliephillips/tinyMQTT
this one works pretty well so far since these guys fixed the "double" reconnect and enabled the "keepalive" functionality.
I will test with the official MQTT and will report it back when I get time.
thanks
Navas
Is there anyone who can help me achieving reliable MQTT connection? I cannot reconnect to the MQTT server after it disconnects for some reason. I tried with two different MQTT server and results are same. Connecting back to the MQTT server on disconnected event does not work.