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
Callback on_message
called multiple times when using MQTT v5.0
#2555
Comments
This is related to how mqttv5 worded the requirements around overlapping subscriptions, and has been like this since See also: section 3.3.5 here: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html and section 3.3.4 here http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html I suspect that, even though you aren't specified a subscription ID, the fact that if they are used in v5, they must be used, has resulted in mosquitto choosing to send one for each, rather than a single one, with a chain of subids. see also https://mosquitto.org/man/mosquitto-conf-5.html under "allow_duplicate_messages" |
Okay, I understand now, thanks. But is there a way to tell the broker to send only one message (as it was with MQTT v3)? I have set the |
Hello, My perspective on this is that I absolutely do not like having to make checks for duplicate messages. If it were entirely my choice, I'd completely remove that option so that duplicate messages occur for overlapping subscriptions. Preventing duplicate messages means either storing a list of client ids with the message to show where it has been sent, or storing a list of messages that a client has had sent to it, plus being able to efficiently search in those lists. The means at the absolute minimum there need to be as least as many memory allocations as there are per subscribing clients, and that for every single message that comes in. If you had say 1000 clients and 10,000 msgs/s then that's 10M allocations and frees that could be avoided per second. Now, in principle |
Hello,
why is the
on_message
function called 3 times when I am using MQTT v5.0, and exactly once when I am not using MQTT v5.0? The mosquitto version is 2.0.14. Here is the code:Regards
The text was updated successfully, but these errors were encountered: