MQTT - more messages than expected with overlapping topics

Hi all - while looking into & experimenting with MQTT V5 for node-red and testing its features etc, I found an odd scenario. At first I thought this was an MQTT V5 issue or mqtt.js v4.2.1 issue as I had never noticed this before so I loaded up a FRED instance (V1.0.5) - same issue.

Is this expected behaviour?

This is the problem...

Working as expected...

Events are duplicated when adding a matching wildcard subscribe...

Events are tripled when adding a 2nd matching wildcard subscribe...

[{"id":"e67eb652.9b5988","type":"mqtt in","z":"4b3f21a3.ba434","name":"","topic":"people/admins/ted","qos":"2","datatype":"auto","broker":"8d054ea0.7a496","x":570,"y":660,"wires":[["6ff77ce4.6159b4"]]},{"id":"6ff77ce4.6159b4","type":"debug","z":"4b3f21a3.ba434","name":"people/admins/ted","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":770,"y":660,"wires":[]},{"id":"72dbd096.5a21f","type":"inject","z":"4b3f21a3.ba434","name":"people/admins/ted","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"people/admins/ted","payload":"","payloadType":"date","x":590,"y":600,"wires":[["cb8cb1ad.7499f"]]},{"id":"cb8cb1ad.7499f","type":"mqtt out","z":"4b3f21a3.ba434","name":"","topic":"","qos":"1","retain":"","broker":"8d054ea0.7a496","x":750,"y":600,"wires":[]},{"id":"5411b0cc.13eb9","type":"mqtt in","z":"4b3f21a3.ba434","name":"","topic":"people/admins/#","qos":"2","datatype":"auto","broker":"8d054ea0.7a496","x":560,"y":720,"wires":[["1974c28a.c6725d"]]},{"id":"1974c28a.c6725d","type":"debug","z":"4b3f21a3.ba434","name":"people/admins/#","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":760,"y":720,"wires":[]},{"id":"49d515f8.2abf7c","type":"mqtt in","z":"4b3f21a3.ba434","name":"","topic":"people/#","qos":"2","datatype":"auto","broker":"8d054ea0.7a496","x":539,"y":780,"wires":[["33c40b7a.1a7c24"]]},{"id":"33c40b7a.1a7c24","type":"debug","z":"4b3f21a3.ba434","name":"people/#","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":740,"y":780,"wires":[]},{"id":"8d054ea0.7a496","type":"mqtt-broker","z":"","name":"","broker":"","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"45","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

I would appreciate it if a few people with different versions could test this (let me know your results and node-red version etc)


I just started a clean version of node red 1.2.0-beta - I got 3 messages (as expected) upon publishing to people/admins/ted

Then I modified the qos from 1 to 0 & deploy (modified nodes only) on the MQTT Out (Publish) node & tried again - now I am getting 9 messages as in original post.

Setting qos back to 1, the problem persists (9 messages instead of 3)

Hi Steve. I notice the same. Must be the Brocker you are using for test (echo?)
because when i switch to my local mosquitto with the same flow setup only 3 messages appear as expected.

I tried local mosquito, public mosquito and public emqx.

Can you confirm after changing QoS or something else & deploying of the issue surfaces for your local broker?

mosquitto version 1.5.7 running on raspberry pi 4
tried Qos 0, 1 and 2 for all .. and always get 3 messages

It's a known issue in Node-RED when you have overlapping subscriptions with certain broker implementations. The full explanation is too much for me to tap out on my phone, so suffice to say it's known and won't be fixed.

Have a search for previous posts from me that mention overlapping subscriptions to get the full explanation.

Is this the post you refer to Nick?

No thats fine - I was unsure if I had caused the issue or if it was somehow related to recent mqtt version upgrade.

I can carry on assessing MQTT V5 and how it might be implemented in node-red. I hope to present something soon - just needed to get this out of the way as it has had me stumped for some time.

@UnborN so I have since found that the multiple messages occurs with local mosquitto when V5 flag is set. Things are now a bit clearer after yours and Nicks posts. Cheers.

When it comes to implementing V5 in node-red there is probably a need to document this behaviour. Some how.

Somewhat interestingly, when specifying MQTT V5 for HiveMQ and use the example flow above, you only get the 3 messages (unlike mosquitto and EMQX which flips to outputting 9).

To me, that sounds like a bug in Mosquitto since it is different behaviour between v3 and v5. Certainly worth raising with them?

3 - 5 is a major bump, The behaviour is within the new spec.

I was thinking that (major version change) was a possible reason for the behaviour change (in mosquitto broker) but haven't looked into it TBH.

Still worth asking the Mosquitto devs I would think - they might not have spotted it or they may already be aware.

It was the subject of much debate

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.