mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 07:31:07 +01:00
Merge pull request #5156 from node-red/pr_4989
Ensure generated mqtt clientId uses only valid chars
This commit is contained in:
@@ -675,7 +675,7 @@ module.exports = function(RED) {
|
||||
node.options.password = node.password;
|
||||
node.options.keepalive = node.keepalive;
|
||||
node.options.clean = node.cleansession;
|
||||
node.options.clientId = node.clientid || 'nodered_' + RED.util.generateId();
|
||||
node.options.clientId = node.clientid || 'nodered' + RED.util.generateId();
|
||||
node.options.reconnectPeriod = RED.settings.mqttReconnectTime||5000;
|
||||
delete node.options.protocolId; //V4+ default
|
||||
delete node.options.protocolVersion; //V4 default
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('MQTT Nodes', function () {
|
||||
mqttBroker.should.have.property('options');
|
||||
mqttBroker.options.should.have.property('clean', true);
|
||||
mqttBroker.options.should.have.property('clientId');
|
||||
mqttBroker.options.clientId.should.containEql('nodered_');
|
||||
mqttBroker.options.clientId.should.containEql('nodered');
|
||||
mqttBroker.options.should.have.property('keepalive').type("number");
|
||||
mqttBroker.options.should.have.property('reconnectPeriod').type("number");
|
||||
//as this is not a v5 connection, ensure v5 properties are not present
|
||||
@@ -894,4 +894,4 @@ function nextTopic(topic) {
|
||||
return (base_topic + topic + String(topicNo));
|
||||
}
|
||||
|
||||
//#endregion HELPERS
|
||||
//#endregion HELPERS
|
||||
|
||||
Reference in New Issue
Block a user