I am using paho mqtt client in GO to connect to a broker. Everything works fine for a while, in which I can publish to topics and listen to any subscription. After a while the client loses connection to the broker, for no apparent reason with this log:
[MQTT] ERROR: 2018/09/04 17:31:30 [net] outgoing stopped with error write tcp IP1 -> IP2: write: broken pipe
[MQTT] ERROR: 2018/09/04 17:31:30 [net] logic received from error channel, other components have errored, stopping
I am connecting to the broker like this:
opts := mqtt.NewClientOptions().
AddBroker(broker).
SetClientID(fmt.Sprintf("%s-%v", ProgramName, time.Now().Unix())).
SetUsername(username).
SetPassword(password).
SetOrderMatters(true)
if tlsConfig != nil {
opts.SetTLSConfig(tlsConfig)
}
pahoClient := mqtt.NewClient(opts)
client = &DefaultMQTTClient{
c: pahoClient,
subscribeQoS: subscribeQoS,
publishQoS: publishQoS,
name: name,
log: Log.WithPrefix("mqtt").WithFields(logrus.Fields{
"name": name,
"broker": broker,
}),
}
client.Log().Debug("connecting to mqtt broker")
if err = client.Connect(); err != nil {
err = client.Log().Trace(err, "failed to connect to mqtt broker")
return
}
client.Log().Info("established connection with mqtt broker")
And the version of paho that I am using is 1.0.0. Any hint is welcome!