mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3374 from Steve-Mcl/mqtt-reconnect-fix
Mqtt reconnect fix
This commit is contained in:
commit
08732bac0f
@ -288,7 +288,7 @@ module.exports = function(RED) {
|
||||
//TODO: delete msg.responseTopic - to prevent it being resent?
|
||||
}
|
||||
}
|
||||
topicOK = topicOK && !/[\+#]/.test(msg.topic);
|
||||
topicOK = topicOK && !/[\+#\b\f\n\r\t\v\0]/.test(msg.topic);
|
||||
|
||||
if (topicOK) {
|
||||
node.brokerConn.publish(msg, done); // send the message
|
||||
@ -730,12 +730,18 @@ module.exports = function(RED) {
|
||||
node.client.on("reconnect", function() {
|
||||
setStatusConnecting(node, true);
|
||||
});
|
||||
//TODO: what to do with this event? Anything? Necessary?
|
||||
//Broker Disconnect - V5 event
|
||||
node.client.on("disconnect", function(packet) {
|
||||
//Emitted after receiving disconnect packet from broker. MQTT 5.0 feature.
|
||||
var rc = packet && packet.properties && packet.properties.reasonString;
|
||||
var rc = packet && packet.properties && packet.reasonCode;
|
||||
//TODO: If keeping this event, do we use these? log these?
|
||||
const rc = (packet && packet.properties && packet.reasonCode) || packet.reasonCode;
|
||||
const rs = packet && packet.properties && packet.properties.reasonString || "";
|
||||
const details = {
|
||||
broker: (node.clientid?node.clientid+"@":"")+node.brokerurl,
|
||||
reasonCode: rc,
|
||||
reasonString: rs
|
||||
}
|
||||
node.log(RED._("mqtt.state.broker-disconnected", details));
|
||||
setStatusDisconnected(node, true);
|
||||
});
|
||||
// Register disconnect handlers
|
||||
node.client.on('close', function () {
|
||||
|
@ -442,7 +442,8 @@
|
||||
"state": {
|
||||
"connected": "Connected to broker: __broker__",
|
||||
"disconnected": "Disconnected from broker: __broker__",
|
||||
"connect-failed": "Connection failed to broker: __broker__"
|
||||
"connect-failed": "Connection failed to broker: __broker__",
|
||||
"broker-disconnected": "Broker __broker__ disconnected client: __reasonCode__ __reasonString__"
|
||||
},
|
||||
"retain": "Retain",
|
||||
"output": {
|
||||
|
Loading…
Reference in New Issue
Block a user