Skip to content

Fix reconnection issues mqtt#8821

Merged
helenosheaa merged 3 commits intomasterfrom
fix-reconnection-issues
Feb 11, 2021
Merged

Fix reconnection issues mqtt#8821
helenosheaa merged 3 commits intomasterfrom
fix-reconnection-issues

Conversation

@helenosheaa
Copy link
Copy Markdown
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
Copy Markdown
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
@helenosheaa helenosheaa requested a review from ssoroka February 9, 2021 19:22
}

m.opts = opts
m.messages = make(map[telegraf.TrackingID]bool)
Copy link
Copy Markdown
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{}

return t.sessionPresent
}

func (t *FakeToken) Done() <-chan struct{} {
Copy link
Copy Markdown
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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

inputs.mqtt_consumer reconnects after network interruption but only yields timeouts thereafter MQTT connection failures with Mosquitto

3 participants