MQTT.js
MQTT.js copied to clipboard
when mqtt server goes offline (host shut off), and comes back online....
when mqtt server goes offline (host shut off), and comes back online.... this library's reconnect handler does not recover and does not reconnect.
Need example showing how to accomplish this
Can you provide a sample of your connection code?
Note: when reconnectPeriod is set to 0 reconnection is disabled.
reference
The code is exactly the same as the example that you provide
On Mon, Apr 4, 2022 at 4:37 AM Farhan Yahaya @.***> wrote:
Can you provide a sample of your connection code? Note: when reconnectPeriod is set to 0 reconnection is disabled. reference https://github.com/mqttjs/MQTT.js#client
— Reply to this email directly, view it on GitHub https://github.com/mqttjs/MQTT.js/issues/1466#issuecomment-1087447653, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABS6UTZC32KC3Q22J7TBYELVDLH73ANCNFSM5SD7DMXA . You are receiving this because you authored the thread.Message ID: @.***>
I think I have the same problem - if server goes away and client keeps trying to publish,
- client says error / connection refused
- error handler fires - client "ends"
- client disconnecting error (below) upon publish more events - no recovery when server is back online
Error: client disconnecting
at MqttClient._checkDisconnecting (c:\...\node_modules\mqtt\lib\client.js:577:26)
at MqttClient.publish (c:\...\node_modules\mqtt\lib\client.js:617:12)
...
All examples show using client.end() in the error handler.
mqttClient.on('error', function (err) {
console.log(err);
client.end();
});
When I remove client.end(), the client library reconnects successfully when the server back and continues to send messages as expected. Other clients listening successfully reconnect on their own and receive messages.
I think it's related to this open issue: #1284
Also, can someone clarify why/when we would want to call end() ?
This is against the eclipse mqtt broker.
MQTT 5.0.0 BETA is now available! Try it out and give us feedback: npm i mqtt@beta. It may fix your issues