add ids to mqtt

This commit is contained in:
Matthew R. Kasun
2022-02-08 15:05:37 -05:00
parent 5c881107ff
commit 1cd25a996c
3 changed files with 36 additions and 0 deletions

View File

@@ -93,6 +93,8 @@ func SetupMQTT(cfg *config.ClientConfig) mqtt.Client {
opts := mqtt.NewClientOptions()
server := getServerAddress(cfg)
opts.AddBroker(server + ":1883")
id := ncutils.MakeRandomString(23)
opts.ClientID = id
opts.SetDefaultPublishHandler(All)
client := mqtt.NewClient(opts)
tperiod := time.Now().Add(12 * time.Second)