Skip to content

fix: subscribe to topics on reconnection when session persistence is not enabled or broken#3462

Merged
reubenmiller merged 2 commits intothin-edge:mainfrom
reubenmiller:fix-mqtt-topic-sub-without-session
Mar 11, 2025
Merged

fix: subscribe to topics on reconnection when session persistence is not enabled or broken#3462
reubenmiller merged 2 commits intothin-edge:mainfrom
reubenmiller:fix-mqtt-topic-sub-without-session

Conversation

@reubenmiller
Copy link
Copy Markdown
Contributor

@reubenmiller reubenmiller commented Mar 11, 2025

Proposed changes

Resubscribe to MQTT topics on reconnection when the no session is present. No session is present when mosquitto persistence has not been configured, or inaccessible (e.g. corrupt or incorrect ownership/permissions).

Previously, the reconnection logic was assuming that the only time the client needs to resubscribe to the MQTT topics is when an anonymous session is used. However if the MQTT broker persistence layer is not working, then the client should be checking if a session is present or not, and then resubscribing to the topics if no session was restored.

The most notable symptom without this change was that the tedge-agent would stop reacting to operations sent via MQTT if it would be disconnected from the local MQTT broker and if the MQTT broker persistence layer was not working or enabled. Restarting the tedge-agent service would "fix" the situation but only until the next reconnection event.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@reubenmiller reubenmiller added the theme:mqtt Theme: mqtt and mosquitto related topics label Mar 11, 2025
@reubenmiller reubenmiller temporarily deployed to Test Pull Request March 11, 2025 07:45 — with GitHub Actions Inactive
@reubenmiller reubenmiller changed the title fix: subscribe to topics on reconnection and session persistence is not enabled or broken fix: subscribe to topics on reconnection when session persistence is not enabled or broken Mar 11, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 11, 2025

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
592 0 3 592 100 1h36m7.333236999s

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/common/mqtt_channel/src/connection.rs 0.00% 1 Missing ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Copy link
Copy Markdown
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

…nce is disabled or broken

Signed-off-by: reubenmiller <reuben.d.miller@gmail.com>
Signed-off-by: reubenmiller <reuben.d.miller@gmail.com>
@reubenmiller reubenmiller force-pushed the fix-mqtt-topic-sub-without-session branch from 5195f72 to 0aff528 Compare March 11, 2025 10:53
@reubenmiller reubenmiller temporarily deployed to Test Pull Request March 11, 2025 10:53 — with GitHub Actions Inactive
@reubenmiller reubenmiller enabled auto-merge March 11, 2025 11:14
@reubenmiller reubenmiller added this pull request to the merge queue Mar 11, 2025
Merged via the queue into thin-edge:main with commit b4c0854 Mar 11, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:mqtt Theme: mqtt and mosquitto related topics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants