Skip to content

Commit 86d46b0

Browse files
dont assume scheme
1 parent cabf4b1 commit 86d46b0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

internal/mqtt/mqtt.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ var log = logger.GetLogger()
1313

1414
func connect(clientID string) (mqtt.Client, error) {
1515
broker := config.GetString("mqtt.url")
16-
opts := mqtt.NewClientOptions().AddBroker(fmt.Sprintf("tcp://%s", broker))
16+
opts := mqtt.NewClientOptions().AddBroker(fmt.Sprintf("%s", broker))
1717
opts.SetClientID(clientID)
1818
opts.SetUsername(config.GetString("mqtt.username"))
1919
opts.SetPassword(config.GetString("mqtt.password"))
2020

2121
c := mqtt.NewClient(opts)
2222
token := c.Connect()
23-
if !token.WaitTimeout(5*time.Second) {
23+
if !token.WaitTimeout(5 * time.Second) {
2424
return nil, fmt.Errorf("timeout when connecting to mqtt broker")
2525
}
26-
26+
2727
if token.Error() != nil {
2828
return nil, token.Error()
2929
}
@@ -38,7 +38,7 @@ func PublishWrapper(topic string, msg string) error {
3838

3939
// creates a connection to broker and sends the payload
4040
func Publish(payload []byte, topic string) error {
41-
if ! config.GetBool("mqtt.enabled") {
41+
if !config.GetBool("mqtt.enabled") {
4242
log.Debugf("MQTT is disabled, skipping publish to topic %v", topic)
4343
return nil
4444
}
@@ -70,8 +70,8 @@ func Publish(payload []byte, topic string) error {
7070
// if this doesnt return true, it timed out
7171
if !token.WaitTimeout(10 * time.Second) {
7272
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
7575
continue
7676
}
7777

web/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ <h2>MQTT</h2>
269269
<div>
270270
<label for="mqtt-url">MQTT URL with port
271271
<span class="description">
272-
URL - "tcp://x.x.x.x:1883" <- Must have tcp:// or equivalent schema </span>
272+
URL - "tcp://x.x.x.x:1883" <- Must have tcp:// or equivalent scheme </span>
273273
</label>
274274

275-
<input type="text" id="mqtt-url" name="mqtt.url" placeholder="http://x.x.x.x:1883">
275+
<input type="text" id="mqtt-url" name="mqtt.url" placeholder="tcp://x.x.x.x:1883">
276276
</div>
277277
<div>
278278
<label for="mqtt-username">Username

0 commit comments

Comments
 (0)