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 keep-alive disconnects on system time changes #3168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

karlri
Copy link

@karlri karlri commented Nov 22, 2024

Treat this as a request for comments for now. Potentially mosquitto_lib_init should be called instead and not just mosqutitto_time_init.

Calling mosqutitto_time_init seems to fix issues with changing system time back and forth one hour on Linux resulting in all clients with keep-alive being kicked instantly.

mosquitto_time_init must be called before calling mosquitto_time, otherwise time_clock will be 0 in mosquitto_time (per C99 standard initialized to 0 since there is no explicit init value) which will cause the realtime clock to be used when the intention seems to be to use the best monotonic clock supported by the platform.

That in turn causes the broker to kick clients when system time is changed because it's misinterpreted as clients failing on their keep-alive promises.

I need to check with my employer if I can sign the below referenced agreement.

  • Have you signed the Eclipse Contributor Agreement, using the same email address as you used in your commits?
  • Do each of your commits have a "Signed-off-by" line, with the correct email address? Use "git commit -s" to generate this line for you.
  • If you are contributing a new feature, is your work based off the develop branch?
  • If you are contributing a bugfix, is your work based off the fixes branch?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run make test with your changes locally?

mosquitto_time_init must be called before calling mosquitto_time,
otherwise time_clock will be 0 in mosquitto_time which will cause the
realtime clock to be used when the intention seems to be to use the
best monotonic clock supported by the platform.

That in turn causes the broker to kick clients when system time is
changed because it's misinterpreted as clients failing on their
keep-alive promises.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant