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

MQTT 5.0 / Session Expiry Interval only works within one run of mosquitto #2610

Closed
JSchy65 opened this issue Aug 10, 2022 · 4 comments
Closed

Comments

@JSchy65
Copy link

JSchy65 commented Aug 10, 2022

mosquitto broker version 1.6.15. (Oracle Linux 8)

MQTT 5.0 Specification chapter 3.1.2.11.2 Session Expiry Interval
"Non-normative comment:
The clock in the Client or Server may not be running for part of the time interval, for instance because the Client or Server are not running. This might cause the deletion of the state to be delayed."

As I understood the "Session Expiry Interval", it should be maintained even if the MQTT broker is not running.
That means, if a subscriber sets the Session Expiry Interval to e.g. 30s and disconnects, the session should
be removed even if the MQTT broker is down in meantime, probably in the next run of the MQTT broker.

Currently, it seems that mosquitto is not doing that.

Reproduction:

Probably remove mosquitto.db to have a clean start.

Start mosquitto with the following configuration:
sys_interval 1
persistence true

Use subscribers to permanently check some values:
mosquitto_sub -p 1883 -t '$SYS/broker/clients/connected'
mosquitto_sub -p 1883 -t '$SYS/broker/clients/total'

what leads to:

clients/connected 2
clients/total 2

mosquitto_sub -p 1883 -q 1 -t test/# -c -i abc123 -D disconnect session-expiry-interval 30 -d

clients/connected 3
clients/total 3

stop subscriber / ctrl-c / -> disconnect

immediately start a stopwatch

clients/connected 2
clients/total 3

stop mosquitto broker / ctrl-c

wait some seconds

start mosquitto broker again

wait until > 30s are left since stop of subscriber

clients/connected 2
clients/total 3 !!!!! should be 2 ??

It's the same result with -q 2

Regardless how long you wait now, the subscriber will be not removed even the session-expiry-interval is passed.

My expectation is, that a session-expiry-interval is mantained even if the MQTT broker is stopped or powered off in meantime.

Probably similar issue like #2546 (persistent_client_expiration only works within one run of mosquitto) ?

Thank You very much, Regards
Joachim Schachermayer

@ralight
Copy link
Contributor

ralight commented Aug 11, 2022

Thank you for the report and clear description of how to reproduce the problem. This issue has already been addressed in more recent versions of the broker, and I only intend to make security related fixes to the 1.6.x line of releases. Are you able to upgrade to 2.0.14?

@JSchy65
Copy link
Author

JSchy65 commented Aug 12, 2022

I tested now with Mosquitto 2.0.14 on Ubuntu 20.04.3 LTS. There is the same behaviour as described above.

On Oracle Linux 8 there is only mosquitto 1.6.15 available. But we check if we can upgrade to 2.0.14.

@ralight
Copy link
Contributor

ralight commented Aug 12, 2022

My apologies, I may have been testing against the fixes branch which does contain a relevant change for this, rather than against 2.0.14. I am planning the 2.0.15 release for Monday which will include this.

If this is important for your company, maybe I could suggest that the company I work for, Cedalo, may be able to help - perhaps by making Oracle compatible packages for 2.0.15, or some other solution: https://cedalo.com/contact-us/

@JSchy65
Copy link
Author

JSchy65 commented Aug 17, 2022

In meantime I retested with 2.0.15 and it behaved as expected -> issue is fixed.

Thank you very much for your support.

@JSchy65 JSchy65 closed this as completed Aug 17, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants