Update packages/node_modules/@node-red/nodes/core/network/10-mqtt.js

Co-authored-by: Stephen McLaughlin <44235289+Steve-Mcl@users.noreply.github.com>
This commit is contained in:
Phil Day 2022-05-09 16:22:50 +01:00 committed by GitHub
parent 82672a825d
commit c87ff3ca26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -719,6 +719,11 @@ module.exports = function(RED) {
setStatusConnecting(node, true);
try {
node.serverProperties = {};
if(node.client) {
//belt and braces to avoid left over clients
node.client.end(true);
node._clientRemoveListeners();
}
node.client = mqtt.connect(node.brokerurl, node.options);
node.client.setMaxListeners(0);
let callbackDone = false; //prevent re-connects causing node._clientOn('connect' firing callback multiple times