Update 10-mqtt.js to meet mqtt specification of 23 length clientid

MQTT clientid:
If automatically generating a clientid for user it should be =< 23
Right now it generates length of 24.

See mqtt specifications --> http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc385349242
"The Server MUST allow ClientIds which are between 1 and 23 UTF-8 encoded bytes in length,..."

As 23 is the minimum we should shoot for this specification.

I noticed this when connecting to a mqtt server that was set to minimum spec. it would not connect! Sure I can generate my own ID or fill it in with less than 23 but it did confuse me for 15min.
pull/4989/head
meeki007 2024-12-12 11:15:23 -05:00 committed by GitHub
parent aa1d5ad06b
commit abceb1185b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -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