Repository navigation
Publish online again when a broker reconnects - #34
Merged
Merged
Conversation
When the link drops the broker publishes our will (offline), and paho's auto-reconnect brought the connection back without a new status, so the bot read as offline until the next status tick, up to statusInterval (300 s by default). An OnConnect handler now publishes online on every connect after the first; the first is still published by the caller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a broker blip the bot read as offline for up to
statusInterval(300 s by default) while it was running fine. Found in the round 2 on-air test.When the link drops, the broker publishes the will (
offline). paho's auto-reconnect then restores the connection, but nothing published a new status until the next tick. Long-standing, not from this week's changes.Fix
connectBrokersets anOnConnecthandler that publishesonlineon every connect after the first (onReconnect). paho calls the handler for the initial connect too, and that one is already published byconnectAndRetry/ the token refresh, so it is skipped to avoid a double.connectBrokernow takes the broker client and context so the handler can publish.Testing
TestOnReconnectSkipsFirstConnect: first connect does nothing, each later one fires.onlineat all (only theofflineat shutdown 30 s later);reconnectedlogged andonlinepublished right after the reconnect. Startup still publishes exactly oneonline.-race.