-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix reconnection issues mqtt #8821
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤝 ✅ CLA has been signed. Thank you!
@@ -184,6 +184,7 @@ func (m *MQTTConsumer) Init() error { | |||
} | |||
|
|||
m.opts = opts | |||
m.messages = make(map[telegraf.TrackingID]bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a big deal, but I prefer not using make when there's no allocation size
m.messages = make(map[telegraf.TrackingID]bool) | |
m.messages = map[telegraf.TrackingID]bool{} |
@@ -84,6 +85,10 @@ func (t *FakeToken) SessionPresent() bool { | |||
return t.sessionPresent | |||
} | |||
|
|||
func (t *FakeToken) Done() <-chan struct{} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't appear to be used anywhere. is this for an interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I updated the package the tests wouldn't run until I added this
(cherry picked from commit f3a208e)
Closes #8722, #7648
When there is a network interruption or anything to cause a connection failure the input would not recover without restarting Telegraf.
Eg the following:
E.g connection lost EOF or connection lost pingresp not received
Would cause it to repeat loop on the messages below and not resume gathering metrics without a restart.
Upgraded to eclipse/paho.mqtt.golang v1.3.0 which includes fixes for reconnection errors.
Moved the make of m.messages into the Init function so it is only called once rather than on every reconnect, so in the event of a reconnection error once it reconnects it recovers.