From e3c09465531736ad692523dac98aafcc969d4c5d Mon Sep 17 00:00:00 2001 From: kerwincui <164770707@qq.com> Date: Wed, 23 Mar 2022 14:42:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0yml=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- springboot/wumei-admin/src/main/resources/application.yml | 3 ++- .../wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxClient.java | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/springboot/wumei-admin/src/main/resources/application.yml b/springboot/wumei-admin/src/main/resources/application.yml index 23db7a5f..9d7079ea 100644 --- a/springboot/wumei-admin/src/main/resources/application.yml +++ b/springboot/wumei-admin/src/main/resources/application.yml @@ -83,10 +83,11 @@ spring: username: wumei-smart # 账号 password: wumei-smart # 密码 host-url: tcp://localhost:1883 # mqtt连接tcp地址 - client-id: ${random.int} # 客户端Id,不能相同,采用随机数 ${random.value} + client-id: ${random.int} # 客户端Id,不能相同,采用随机数 ${random.value} default-topic: test # 默认主题 timeout: 30000 # 超时时间 keepalive: 30 # 保持连接 + clearSession: true # 清除会话(设置为false,断开连接,重连后使用原来的会话 保留订阅的主题,能接收离线期间的消息) task: execution: pool: diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxClient.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxClient.java index 4b392174..93735d24 100644 --- a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxClient.java +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mqtt/EmqxClient.java @@ -117,8 +117,6 @@ public class EmqxClient { options.setKeepAliveInterval(keepalive); //设置自动重新连接 options.setAutomaticReconnect(true); - /*设置为false,断开连接,不清除session,重连后还是原来的session - 保留订阅的主题,能接收离线期间的消息*/ options.setCleanSession(clearSession); logger.debug("====>>>>设置mqtt参数成功"); }