mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #4156 from node-red/4133-mqtt-v5-disconnects-when-subscribing-to-aws-core-broker
Dont use `subscriptionIdentifier` if broker doesnt support it
This commit is contained in:
commit
5d698d66d0
@ -697,7 +697,8 @@ module.exports = function(RED) {
|
|||||||
node.options.rejectUnauthorized = (node.verifyservercert == "true" || node.verifyservercert === true);
|
node.options.rejectUnauthorized = (node.verifyservercert == "true" || node.verifyservercert === true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
node.v5 = () => node.options && node.options.protocolVersion == 5
|
||||||
|
node.subscriptionIdentifiersAvailable = () => node.v5() && node.serverProperties && node.serverProperties.subscriptionIdentifiersAvailable
|
||||||
n.autoConnect = n.autoConnect === "false" || n.autoConnect === false ? false : true;
|
n.autoConnect = n.autoConnect === "false" || n.autoConnect === false ? false : true;
|
||||||
node.setOptions(n, true);
|
node.setOptions(n, true);
|
||||||
|
|
||||||
@ -920,7 +921,12 @@ module.exports = function(RED) {
|
|||||||
};
|
};
|
||||||
node.subscriptions[topic][ref] = sub;
|
node.subscriptions[topic][ref] = sub;
|
||||||
if (node.connected) {
|
if (node.connected) {
|
||||||
|
const subIdsAvailable = node.subscriptionIdentifiersAvailable()
|
||||||
node._clientOn('message',sub.handler);
|
node._clientOn('message',sub.handler);
|
||||||
|
// if the broker doesn't support subscription identifiers (e.g. AWS core), then don't send them
|
||||||
|
if (options.properties && options.properties.subscriptionIdentifier && subIdsAvailable !== true) {
|
||||||
|
delete options.properties.subscriptionIdentifier
|
||||||
|
}
|
||||||
node.client.subscribe(topic, options);
|
node.client.subscribe(topic, options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user