From c4ad8ea9c6119cfd1e2fdd83e4acd7b753b49d52 Mon Sep 17 00:00:00 2001 From: YuShifan <894402575bt@gmail.com> Date: Mon, 14 Feb 2022 15:20:20 +0800 Subject: [PATCH] feat(connection): backward support for mqtt 3.1 --- src/utils/mqttUtils.ts | 5 ++++- src/views/connections/ConnectionForm.vue | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/mqttUtils.ts b/src/utils/mqttUtils.ts index 721b55c22..b0b3b8ba4 100644 --- a/src/utils/mqttUtils.ts +++ b/src/utils/mqttUtils.ts @@ -23,6 +23,7 @@ const setWillMQTT5Properties = (option: WillPropertiesModel) => { const getClientOptions = (record: ConnectionModel): IClientOptions => { const mqttVersionDict = { + '3.1': 3, '3.1.1': 4, '5.0': 5, } @@ -42,7 +43,7 @@ const getClientOptions = (record: ConnectionModel): IClientOptions => { rejectUnauthorized, clientIdWithTime, } = record - const protocolVersion = mqttVersionDict[mqttVersion as '3.1.1' | '5.0'] + const protocolVersion = mqttVersionDict[mqttVersion as '3.1' | '3.1.1' | '5.0'] const options: IClientOptions = { clientId, keepalive, @@ -69,6 +70,8 @@ const getClientOptions = (record: ConnectionModel): IClientOptions => { if (properties && Object.keys(properties).length > 0) { options.properties = properties } + } else if (protocolVersion === 3) { + options.protocolId = 'MQIsdp' } // SSL if (ssl) { diff --git a/src/views/connections/ConnectionForm.vue b/src/views/connections/ConnectionForm.vue index 85f25cc46..c75ddad35 100644 --- a/src/views/connections/ConnectionForm.vue +++ b/src/views/connections/ConnectionForm.vue @@ -306,6 +306,7 @@ +