Skip to content
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

Merged
merged 3 commits into from
Feb 11, 2021
Merged

Fix reconnection issues mqtt #8821

merged 3 commits into from
Feb 11, 2021

Conversation

helenosheaa
Copy link
Member

@helenosheaa helenosheaa commented Feb 5, 2021

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.

Previous collection has not completed; scheduled collection  
Collection took longer than expected; not complete after interval of 10s 

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.

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Feb 5, 2021
Copy link
Contributor

@telegraf-tiger telegraf-tiger bot left a 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!

@sjwang90 sjwang90 linked an issue Feb 8, 2021 that may be closed by this pull request
@@ -184,6 +184,7 @@ func (m *MQTTConsumer) Init() error {
}

m.opts = opts
m.messages = make(map[telegraf.TrackingID]bool)
Copy link
Contributor

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

Suggested change
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{} {
Copy link
Contributor

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?

Copy link
Member Author

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

@helenosheaa helenosheaa merged commit f3a208e into master Feb 11, 2021
@helenosheaa helenosheaa deleted the fix-reconnection-issues branch February 11, 2021 16:45
ssoroka pushed a commit that referenced this pull request Feb 17, 2021
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug
Projects
None yet
3 participants