From f2058606556356ab0f60e86aa78f860d40025788 Mon Sep 17 00:00:00 2001 From: lucas Date: Mon, 9 Jun 2025 16:11:15 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0mq=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbOperate/mqttHelper.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dbOperate/mqttHelper.go b/dbOperate/mqttHelper.go index c0f66b2..c720995 100644 --- a/dbOperate/mqttHelper.go +++ b/dbOperate/mqttHelper.go @@ -43,7 +43,10 @@ reConn: opts.SetUsername(the.UserName) opts.SetPassword(the.Password) opts.SetClientID(the.ClientId) + opts.SetCleanSession(false) // 通常需要关闭 CleanSession + opts.SetResumeSubs(true) // 启用 ResumeSubs opts.SetOnConnectHandler(the.reConn2Subscribe) + opts.SetMaxReconnectInterval(10 * time.Second) if sslEnable { opts.SetTLSConfig(NewTlsConfig(caCertPath, clientCertPath, clientKeyPath)) }