Quellcode durchsuchen

fix(mqtt): 修改MQTT配置以支持持久会话

- 将client-id从随机UUID改为固定值,便于识别和调试
- 设置clean-session为false,启用会话持久化功能
- 统一开发、本地和生产环境的MQTT客户端配置
-修正MqttConfig中的属性注入键名错误,确保配置正确加载
hxd vor 1 Tag
Ursprung
Commit
451d335a87

+ 1 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/config/MqttConfig.java

@@ -57,7 +57,7 @@ public class MqttConfig {
     @Value("${mqtt.keep.alive.interval:60}")
     private int keepAliveInterval;
 
-    @Value("${mqtt.clean.session:true}")
+    @Value("${mqtt.clean-session:true}")
     private boolean cleanSession;
 
     // ===========================================

+ 3 - 2
portal-service-server/src/main/resources/bootstrap-dev.yml

@@ -109,12 +109,13 @@ sa-token:
 mqtt:
   enabled: true
   broker: tcp://8.130.28.21:1883
-  client-id: ${spring.application.name}-${random.uuid}
+#  client-id: ${spring.application.name}-${random.uuid}
+  client-id: portal-service-server-dev
   username: admin
   password: public
   timeout: 30
   keepalive: 60
-  clean-session: true
+  clean-session: false
   automatic-reconnect: true
 
 # oss 存储

+ 3 - 2
portal-service-server/src/main/resources/bootstrap-local.yml

@@ -109,12 +109,13 @@ sa-token:
 mqtt:
   enabled: true
   broker: tcp://8.130.28.21:1883
-  client-id: ${spring.application.name}-${random.uuid}
+#  client-id: ${spring.application.name}-${random.uuid}
+  client-id: portal-service-server-02
   username: admin
   password: public
   timeout: 30
   keepalive: 60
-  clean-session: true
+  clean-session: false
   automatic-reconnect: true
 
 # oss 存储

+ 3 - 2
portal-service-server/src/main/resources/bootstrap-prod.yml

@@ -109,12 +109,13 @@ sa-token:
 mqtt:
   enabled: true
   broker: tcp://127.0.0.1:1883
-  client-id: ${spring.application.name}-${random.uuid}
+#  client-id: ${spring.application.name}-${random.uuid}
+  client-id: portal-service-server-prod
   username: admin
   password: public
   timeout: 30
   keepalive: 60
-  clean-session: true
+  clean-session: false
   automatic-reconnect: true
 
 # oss 存储