fix(mqtt): enable clean session and fix hardcoded credentials for gateway

This commit is contained in:
sky121113 2026-04-21 14:37:34 +08:00
parent fed81a12f3
commit 47f7cc3c92

View File

@ -47,9 +47,9 @@ func main() {
opts := mqtt.NewClientOptions()
opts.AddBroker(cfg.MQTTAddr)
opts.SetClientID(cfg.MQTTClientID)
opts.SetUsername("star-cloud-gateway")
opts.SetPassword("StarCloudSecret999") // 與 Redis 中的 hash 對應
opts.SetCleanSession(false)
opts.SetUsername(cfg.MQTTUser)
opts.SetPassword(cfg.MQTTPassword)
opts.SetCleanSession(true)
opts.SetAutoReconnect(true)
opts.SetMaxReconnectInterval(10 * time.Second)