# MQTT - more messages than expected with overlapping topics

**URL:** https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099
**Category:** General
**Created:** [11 October 2020 15:59 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099 "2020-10-11T15:59:06Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 October 2020 15:59 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/1 "2020-10-11T15:59:06Z")

</div>

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...

 ![QTYKoz0Bqb](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/acd00fd3f469f0227918df3cbf69b582260d152a.gif)

Working as expected...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2e0f9bda9d85816d000dfed5f383cb734638fcdc.png)

Events are duplicated when adding a matching wildcard subscribe...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/babddebcd32ce1c92e865b2e8efddb579fdf2ad1.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd35ed7b35560b6382ce6b922d930b015a35f040.png)

```auto
[{"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":"broker.emqx.io","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)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 October 2020 16:11 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/2 "2020-10-11T16:11:19Z")

</div>

### IMPORTANT NOTE:

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)

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [11 October 2020 16:37 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/3 "2020-10-11T16:37:15Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 October 2020 16:40 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/4 "2020-10-11T16:40:21Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [11 October 2020 16:45 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/5 "2020-10-11T16:45:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [11 October 2020 17:12 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/6 "2020-10-11T17:12:33Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 October 2020 17:44 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/7 "2020-10-11T17:44:06Z")

</div>

> [@knolleary](#):
>
> Have a search for previous posts from me that mention overlapping subscriptions to get the full explanation.

Is [this](https://discourse.nodered.org/t/repeated-messages-with-vernemq-mqtt-broker/26759/8) the post you refer to Nick?

> [@knolleary](#):
>
> 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.

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.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 October 2020 18:26 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/8 "2020-10-11T18:26:33Z")

</div>

@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.

EDIT...  
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).

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [11 October 2020 21:57 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/9 "2020-10-11T21:57:30Z")

</div>

> [@Steve-Mcl](#):
>
> 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.

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

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [11 October 2020 22:22 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/10 "2020-10-11T22:22:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 October 2020 22:25 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/11 "2020-10-11T22:25:33Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [11 October 2020 22:29 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/12 "2020-10-11T22:29:40Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [11 October 2020 22:47 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/13 "2020-10-11T22:47:19Z")

</div>

It was the subject of much debate

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [25 October 2020 22:47 UTC](https://discourse.nodered.org/t/mqtt-more-messages-than-expected-with-overlapping-topics/34099/14 "2020-10-25T22:47:20Z")

</div>

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