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 MQTT auto-reconnect with custom topic issues + update mqtt #2197

Conversation

Terdious
Copy link
Contributor

@Terdious Terdious commented Jan 16, 2025

The code changes fix the MQTT reconnect logic in the connect.js file. It now checks if the reconnecting flag is set before disconnecting. If the flag is not set, it sets the flag to true, logs a warning message, and attempts to reconnect to the MQTT server after a 500ms delay. Once the reconnection is complete, the flag is set back to false. If the flag is already set, it simply disconnects from the MQTT server. Additionally, the index.js file now initializes the reconnecting flag to false.

Pull Request check-list

To ensure your Pull Request can be accepted as fast as possible, make sure to review and check all of these items:

  • If your changes affects code, did your write the tests?
  • Are tests passing? (npm test on both front/server)
  • Is the linter passing? (npm run eslint on both front/server)
  • Did you run prettier? (npm run prettier on both front/server)
  • Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community (french forum/english forum) for testing before merging.

NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.

Description of change

Fixed mqtt service auto-reconnect issue which was caused by mishandled custom topic issues

The code changes fix the MQTT reconnect logic in the connect.js file. It now checks if the reconnecting flag is set before disconnecting. If the flag is not set, it sets the flag to true, logs a warning message, and attempts to reconnect to the MQTT server after a 500ms delay. Once the reconnection is complete, the flag is set back to false. If the flag is already set, it simply disconnects from the MQTT server. Additionally, the index.js file now initializes the reconnecting flag to false.
Copy link

relativeci bot commented Jan 16, 2025

#2938 Bundle Size — 10.41MiB (0%).

c87479f(current) vs d6461e0 master#2935(baseline)

Warning

Bundle contains 3 duplicate packages – View duplicate packages

Bundle metrics  no changes
                 Current
#2938
     Baseline
#2935
No change  Initial JS 5.64MiB 5.64MiB
No change  Initial CSS 304.89KiB 304.89KiB
Change  Cache Invalidation 0% 54.06%
No change  Chunks 51 51
No change  Assets 173 173
No change  Modules 1511 1511
No change  Duplicate Modules 21 21
No change  Duplicate Code 0.83% 0.83%
No change  Packages 124 124
No change  Duplicate Packages 3 3
Bundle size by type  no changes
                 Current
#2938
     Baseline
#2935
No change  JS 7.43MiB 7.43MiB
No change  IMG 2.54MiB 2.54MiB
No change  CSS 321.79KiB 321.79KiB
No change  Fonts 93.55KiB 93.55KiB
No change  Other 17.79KiB 17.79KiB
No change  HTML 13.58KiB 13.58KiB

Bundle analysis reportBranch Terdious:fix/mqtt-broker-reconne...Project dashboard


Generated by RelativeCIDocumentationReport issue

Remove unused reconnecting flag in MqttHandler
Fix listenToCustomMqttTopicIfNeeded to only subscribe if mqttTopic is provided
Remove reconnect logic in connect.js
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.53%. Comparing base (d6461e0) to head (c87479f).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2197   +/-   ##
=======================================
  Coverage   98.53%   98.53%           
=======================================
  Files         876      876           
  Lines       14432    14432           
=======================================
  Hits        14221    14221           
  Misses        211      211           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Terdious Terdious changed the title Fix MQTT reconnect logic and add reconnect flag Fix MQTT auto-reconnect with custom topic issues Jan 17, 2025
@Terdious Terdious changed the title Fix MQTT auto-reconnect with custom topic issues Fix MQTT auto-reconnect with custom topic issues + update mqtt Jan 17, 2025
@Terdious Terdious added the bug label Jan 17, 2025
@Pierre-Gilles Pierre-Gilles merged commit f416866 into GladysAssistant:master Jan 17, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants