瀏覽代碼

revert the mq setttings back

Max Ma 1 年之前
父節點
當前提交
3a10c88f20
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      mq/mq.go

+ 5 - 5
mq/mq.go

@@ -34,8 +34,8 @@ func setMqOptions(user, password string, opts *mqtt.ClientOptions) {
 	opts.SetAutoReconnect(true)
 	opts.SetConnectRetry(true)
 	opts.SetCleanSession(true)
-	opts.SetConnectRetryInterval(time.Second * 3)
-	opts.SetKeepAlive(time.Second * 5)
+	opts.SetConnectRetryInterval(time.Second * 4)
+	opts.SetKeepAlive(time.Minute)
 	opts.SetCleanSession(true)
 	opts.SetWriteTimeout(time.Minute)
 }
@@ -96,9 +96,9 @@ func SetupMQTT(fatal bool) {
 	})
 	opts.SetConnectionLostHandler(func(c mqtt.Client, e error) {
 		slog.Warn("detected broker connection lost", "err", e.Error())
-		// c.Disconnect(250)
-		// slog.Info("re-initiating MQ connection")
-		// SetupMQTT(false)
+		c.Disconnect(250)
+		slog.Info("re-initiating MQ connection")
+		SetupMQTT(false)
 
 	})
 	mqclient = mqtt.NewClient(opts)