-
Notifications
You must be signed in to change notification settings - Fork 160
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
How to use subscription identifier - Duplicate messages with overlapping topics #596
Comments
Digging even deeper into the code I've found that it's because of the The Paho example that does it correctly is:
|
Thanks for the thorough investigation @TDYJeffreyDevloo. I'm not sure yet if this is by design currently but if so, then this should be a feature request to configure the behavior to use strict topic alias matching. @SgtSilvio should have better insight into this. |
Checklist
issues
.discussions
.Could not look into the discussions as the link does not seem to work.
❓ Question
MQTT5Client fires the callback multiple times if overlapping subscriptions are used. Mosquitto has an option to disable this (see https://mosquitto.org/man/mosquitto-conf-5.html -- allow_duplicate_messages) but MQTT5 describes the subscription_identifier field that is sent with every message so the client can couple the right callback to the right message.
The hiveMQ client does not expose this as an option directly but it is setting the value automatically if the broker supports it.
A small demo app to demonstrate the issue. I am using Mosquitto 2.0.18 with allow_duplicate_messages=true.
Outputs:
Is it possible to use this subscription identifier in our subscriptions to avoid duplicate messages on the client side? Or are there other mechanisms that we can use on the client side of things to avoid this problem? Updating the QoS does not have any effect.
The mosquitto output is
📎 Additional context
There is support for the subscription identifier. I've delved into the code and seen that it's automatically assigned to every subscription, starting from int 1.
The decoder also looks for the identifier but overlapping subscriptions don't see to be using them to invoke the right callback.
The text was updated successfully, but these errors were encountered: