Browse Source

阶段提交:链接删除

yf_zn 1 năm trước cách đây
mục cha
commit
f42083a619

+ 8 - 1
src/main/java/com/yunfeiyun/agmp/iots/core/mqtt/network/MqttCore.java

@@ -211,7 +211,14 @@ public class MqttCore {
      * @throws MqttException
      */
     public void close() throws MqttException {
-        this.mqttClient.close();
+        if (mqttClient.isConnected()) {
+            mqttClient.disconnect();
+            this.mqttClient.close();
+            log.info("【关闭MQTT连接成功】 connectionId: {}", connectionId);
+        }else{
+            log.info("【关闭MQTT连接失败:已关闭】 connectionId: {}", connectionId);
+        }
+
     }
 
     /**