From 14336002f364707c4bc900a75047189dce7fcb85 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 12 Aug 2025 21:32:42 +0800 Subject: [PATCH] =?UTF-8?q?review=EF=BC=9A=E3=80=90iot=20=E7=89=A9?= =?UTF-8?q?=E8=81=94=E7=BD=91=E3=80=91mqtt=20=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/iot/gateway/config/IotGatewayProperties.java | 7 ------- .../iot/gateway/protocol/mqtt/IotMqttUpstreamProtocol.java | 1 + .../protocol/mqtt/manager/IotMqttConnectionManager.java | 3 +++ .../protocol/mqtt/router/IotMqttDownstreamHandler.java | 1 - .../protocol/mqtt/router/IotMqttUpstreamHandler.java | 2 ++ 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/config/IotGatewayProperties.java b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/config/IotGatewayProperties.java index 7684972d29..2c2000fd1f 100644 --- a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/config/IotGatewayProperties.java +++ b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/config/IotGatewayProperties.java @@ -353,7 +353,6 @@ public class IotGatewayProperties { * 连接超时时间(秒) */ private Integer connectTimeoutSeconds = 60; - /** * 保持连接超时时间(秒) */ @@ -363,7 +362,6 @@ public class IotGatewayProperties { * 是否启用 SSL */ private Boolean sslEnabled = false; - /** * SSL 配置 */ @@ -379,27 +377,22 @@ public class IotGatewayProperties { * 密钥证书选项 */ private io.vertx.core.net.KeyCertOptions keyCertOptions; - /** * 信任选项 */ private io.vertx.core.net.TrustOptions trustOptions; - /** * SSL 证书路径 */ private String certPath; - /** * SSL 私钥路径 */ private String keyPath; - /** * 信任存储路径 */ private String trustStorePath; - /** * 信任存储密码 */ diff --git a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/IotMqttUpstreamProtocol.java b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/IotMqttUpstreamProtocol.java index 92ffaedd4b..0d1203abe9 100644 --- a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/IotMqttUpstreamProtocol.java +++ b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/IotMqttUpstreamProtocol.java @@ -50,6 +50,7 @@ public class IotMqttUpstreamProtocol { this.serverId = IotDeviceMessageUtils.generateServerId(mqttProperties.getPort()); } + // TODO @haohao:这里的编写,是不是和 tcp 对应的,风格保持一致哈; @PostConstruct public void start() { // 创建服务器选项 diff --git a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/manager/IotMqttConnectionManager.java b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/manager/IotMqttConnectionManager.java index 11432bc248..eed377535a 100644 --- a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/manager/IotMqttConnectionManager.java +++ b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/manager/IotMqttConnectionManager.java @@ -46,7 +46,9 @@ public class IotMqttConnectionManager { } } catch (Exception e) { // 忽略异常,返回默认值 + // TODO @haohao:这个比较稳定会出现哇? } + // TODO @haohao:这个要枚举下么? return "unknown"; } @@ -194,4 +196,5 @@ public class IotMqttConnectionManager { private boolean authenticated; } + } diff --git a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttDownstreamHandler.java b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttDownstreamHandler.java index 6714c64115..c848833f66 100644 --- a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttDownstreamHandler.java +++ b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttDownstreamHandler.java @@ -69,7 +69,6 @@ public class IotMqttDownstreamHandler { // 5. 发送消息到设备 return sendMessageToDevice(message, connectionInfo, payload); - } catch (Exception e) { if (message != null) { log.error("[handleDownstreamMessage][处理下行消息异常,设备 ID:{},错误:{}]", diff --git a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttUpstreamHandler.java b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttUpstreamHandler.java index 5ce691293c..9714e9104f 100644 --- a/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttUpstreamHandler.java +++ b/yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/mqtt/router/IotMqttUpstreamHandler.java @@ -40,6 +40,7 @@ public class IotMqttUpstreamHandler { public IotMqttUpstreamHandler(IotMqttUpstreamProtocol protocol, IotDeviceMessageService deviceMessageService, + // TODO @haohao:用不到的 deviceService 可以删除哈; IotDeviceService deviceService, IotMqttConnectionManager connectionManager) { this.deviceMessageService = deviceMessageService; @@ -70,6 +71,7 @@ public class IotMqttUpstreamHandler { log.info("[handle][设备认证成功,建立连接,客户端 ID: {},用户名: {}]", clientId, username); + // TODO @haohao:这里是不是少了序号哈? // 设置异常和关闭处理器 endpoint.exceptionHandler(ex -> { log.warn("[handle][连接异常,客户端 ID: {},地址: {}]", clientId, getEndpointAddress(endpoint));