From 89e69d132a128e0a61bc4a0b97fbd5ba993df225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandar=20Novakovi=C4=87?= Date: Wed, 30 May 2018 13:48:40 +0200 Subject: [PATCH] Fix MQTT client id bug (#319) Signed-off-by: Aleksandar Novakovic --- mqtt/mqtt.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mqtt/mqtt.js b/mqtt/mqtt.js index 539fd4e9..ba8159c0 100644 --- a/mqtt/mqtt.js +++ b/mqtt/mqtt.js @@ -71,7 +71,7 @@ aedes.authorizePublish = function (client, packet, publish) { logger.info('authorized publish'); rawMsg = message.RawMessage.encode({ - Publisher: client.id, + Publisher: client.thingId, Channel: channel, Protocol: 'mqtt', Payload: packet.payload @@ -116,11 +116,12 @@ aedes.authenticate = function (client, username, password, acknowledge) { identity = {value: pass}, onIdentify = function(err, res) { if (!err) { - client.id = res.value.toString() || ""; + client.thingId = res.value.toString() || ""; + client.id = client.id || client.thingId; client.password = pass; acknowledge(null, true); } else { - logger.warn('failed to authenticate client with key %s', password); + logger.warn('failed to authenticate client with key %s', pass); acknowledge(err, false); } };