Skip to content

Commit c5536c6

Browse files
committed
Set auto-reconnect to true in order to buffer messages.
When auto-reconnect is set to false, the paho library will not persist messages when the client is offline.
1 parent 59497bd commit c5536c6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

internal/integration/mqtt/backend.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func NewBackend(conf config.Config) (*Backend, error) {
118118
}
119119

120120
b.clientOpts.SetProtocolVersion(4)
121-
b.clientOpts.SetAutoReconnect(false)
121+
b.clientOpts.SetAutoReconnect(true) // this is required for buffering messages in case offline!
122122
b.clientOpts.SetOnConnectHandler(b.onConnected)
123123
b.clientOpts.SetConnectionLostHandler(b.onConnectionLost)
124124

@@ -288,7 +288,6 @@ func (b *Backend) onConnected(c paho.Client) {
288288
func (b *Backend) onConnectionLost(c paho.Client, err error) {
289289
mqttDisconnectCounter().Inc()
290290
log.WithError(err).Error("mqtt: connection error")
291-
b.connectLoop()
292291
}
293292

294293
func (b *Backend) handleDownlinkFrame(c paho.Client, msg paho.Message) {

0 commit comments

Comments
 (0)