Skip to content

Commit

Permalink
Minor improvement on reconnection logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
icemarkom committed May 10, 2021
1 parent 78839b7 commit 2f8fe91
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func handlerReconnecting(c mqtt.Client, co *mqtt.ClientOptions) {

func handlerOnConnectAttempt(b *url.URL, tc *tls.Config) *tls.Config {
log.Println("Attempting to connect to MQTT broker...")

return tc
}

Expand All @@ -37,7 +38,6 @@ func handlerOnConnect(c mqtt.Client) {

func handlerOnConnectionLost(c mqtt.Client, e error) {
log.Printf("Connection to MQTT broker unexpectedly lost: %v.", e)
c.Disconnect(0)
}

func mqttClient() (mqtt.Client, error) {
Expand Down Expand Up @@ -105,7 +105,6 @@ func doMQTT(wg *sync.WaitGroup) {
c, err := mqttClient()
for {
if !c.IsConnected() || !c.IsConnectionOpen() {
c.Connect()
loopWait()
continue
}
Expand Down

0 comments on commit 2f8fe91

Please sign in to comment.