@@ -13,17 +13,17 @@ var log = logger.GetLogger()
13
13
14
14
func connect (clientID string ) (mqtt.Client , error ) {
15
15
broker := config .GetString ("mqtt.url" )
16
- opts := mqtt .NewClientOptions ().AddBroker (fmt .Sprintf ("tcp:// %s" , broker ))
16
+ opts := mqtt .NewClientOptions ().AddBroker (fmt .Sprintf ("%s" , broker ))
17
17
opts .SetClientID (clientID )
18
18
opts .SetUsername (config .GetString ("mqtt.username" ))
19
19
opts .SetPassword (config .GetString ("mqtt.password" ))
20
20
21
21
c := mqtt .NewClient (opts )
22
22
token := c .Connect ()
23
- if ! token .WaitTimeout (5 * time .Second ) {
23
+ if ! token .WaitTimeout (5 * time .Second ) {
24
24
return nil , fmt .Errorf ("timeout when connecting to mqtt broker" )
25
25
}
26
-
26
+
27
27
if token .Error () != nil {
28
28
return nil , token .Error ()
29
29
}
@@ -38,7 +38,7 @@ func PublishWrapper(topic string, msg string) error {
38
38
39
39
// creates a connection to broker and sends the payload
40
40
func Publish (payload []byte , topic string ) error {
41
- if ! config .GetBool ("mqtt.enabled" ) {
41
+ if ! config .GetBool ("mqtt.enabled" ) {
42
42
log .Debugf ("MQTT is disabled, skipping publish to topic %v" , topic )
43
43
return nil
44
44
}
@@ -70,8 +70,8 @@ func Publish(payload []byte, topic string) error {
70
70
// if this doesnt return true, it timed out
71
71
if ! token .WaitTimeout (10 * time .Second ) {
72
72
timeoutErr := fmt .Errorf ("timeout when waiting for mqtt token" )
73
- log .Warning (timeoutErr .Error ())
74
- lastErr = timeoutErr
73
+ log .Warning (timeoutErr .Error ())
74
+ lastErr = timeoutErr
75
75
continue
76
76
}
77
77
0 commit comments