# Mqtt-in repeated messages bug?

**URL:** https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520
**Category:** General
**Created:** [28 March 2019 05:57 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520 "2019-03-28T05:57:43Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 March 2019 05:57 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/1 "2019-03-28T05:57:43Z")

</div>

I see some weird behaviour with the mqtt-in node.

When I change the output to "a parsed JSON object" \> deploy. inject something in mqtt-out node, i get a single response.  
Change the output to "auto-detect" \> deploy. inject something again, the messages are repeated.  
Change it again to json, deploy, inject\> triple messages output and so on.

If i select all nodes\>ctrl-x, deploy, paste, deploy, single messages again.

I can reproduce it. Is this just me ?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 March 2019 15:57 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/2 "2019-03-28T15:57:57Z")

</div>

This is really strange behaviour and it makes mqtt unusable for me.  
Only the initial setup works, touch it and I am stuck with repeated messages until I remove the nodes, deploy and add them again.

@knolleary do I do something wrong or did I find a bug ?

---

<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: [28 March 2019 16:25 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/3 "2019-03-28T16:25:37Z")

</div>

Has the message been published with the retained flag set, meaning youll receive it each time the node subscribes?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 March 2019 17:04 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/4 "2019-03-28T17:04:08Z")

</div>

No retain flag, I have cleared everything on the broker.  
Looking at the subscription, only 1 message exists on the broker, gets repeated in node-red.

Test flow:

```auto
[{"id":"380b9424.fcc454","type":"mqtt in","z":"c0f7a95e.a66d08","name":"","topic":"test/testtopic","qos":"2","datatype":"auto","broker":"73843d1e.7f20dc","x":170,"y":160,"wires":[["a8b9efe1.03a4e"]]},{"id":"a75bc06d.f0bcd8","type":"mqtt out","z":"c0f7a95e.a66d08","name":"","topic":"test/testtopic","qos":"0","retain":"false","broker":"73843d1e.7f20dc","x":410,"y":260,"wires":[]},{"id":"a8b9efe1.03a4e","type":"debug","z":"c0f7a95e.a66d08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":330,"y":160,"wires":[]},{"id":"cc1366c5.2d0998","type":"inject","z":"c0f7a95e.a66d08","name":"","topic":"","payload":"{\"test\":true}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":260,"wires":[["a75bc06d.f0bcd8"]]},{"id":"73843d1e.7f20dc","type":"mqtt-broker","z":"","name":"mqtt","broker":"10.0.0.202","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""}]

```

Inject, single response.  
Change mqtt-in to parsed JSON object, deploy, inject, 2 messages.  
Change it again to auto-detect, 3 messages.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [28 March 2019 18:21 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/5 "2019-03-28T18:21:38Z")

</div>

I could swear that there was a thread in the not too long past that talked about a MQTT broker monitoring tool. But do you think I can find it...nooooo....drat's I thought I had it bookmarked.

Anyway If you can find it, it might shed some light on what the broker is doing.

In addition thei shread might help: [Issues in persisting messages in MQTT Broker using NodeRed MQTT Nodes](https://discourse.nodered.org/t/issues-in-persisting-messages-in-mqtt-broker-using-nodered-mqtt-nodes/4666/4)

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 March 2019 18:38 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/6 "2019-03-28T18:38:40Z")

</div>

I am using [MQTT Explorer](https://github.com/thomasnordquist/MQTT-Explorer)

---

<div class="post-metadata">

### Author: ![guardiande](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@guardiande](https://discourse.nodered.org/u/guardiande)
#### Post date: [28 March 2019 18:44 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/7 "2019-03-28T18:44:32Z")

</div>

> [@bakman2](#):
>
> I can reproduce it. Is this just me ?

I experienced the same thing. Restarting Node Red helped also. The broker wasn't the source of evil.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 March 2019 19:50 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/8 "2019-03-28T19:50:21Z")

</div>

Restarting works temporarily unfortunately

---

<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: [28 March 2019 19:52 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/9 "2019-03-28T19:52:53Z")

</div>

Hi @bakman2

I can't reproduce this with the flow you've provided. I always get the expected one message.

What broker are you using?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [28 March 2019 20:56 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/10 "2019-03-28T20:56:54Z")

</div>

I am using eclipse mosquitto.

It starts repeating once I change something to the mqtt nodes.

---

<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: [28 March 2019 21:09 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/11 "2019-03-28T21:09:48Z")

</div>

I have also seen multiple MQTT messages. In the end I just used an RBE node to handle it.

Should have reported it but suspected it was something I done wrong or an MQTT thing at the time.

Fwiw, I was using the most excellent EMQX broker and node-red v0.20 beta something at the time.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [29 March 2019 08:20 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/12 "2019-03-29T08:20:45Z")

</div>

Then it is not me and it is not the broker.

Using an RBE node is not a "solution", it will work, but I'm not a fan.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [29 March 2019 08:35 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/13 "2019-03-29T08:35:08Z")

</div>

When I switch from `a parsed JSON object` to `auto-detect` I get 2 messages:

```auto
3/29/2019, 9:31:03 AMnode: 48a51ca2.2426a4
livingroom/fan/uptime : msg : Object
object
topic: "livingroom/fan/uptime"
payload: 3493
qos: 0
retain: false
_msgid: "5d655259.c8ae2c"

3/29/2019, 9:31:03 AMnode: 48a51ca2.2426a4
livingroom/fan/uptime : msg : Object
object
topic: "livingroom/fan/uptime"
payload: "3493"
qos: 0
retain: false
_msgid: "956c5dae.87137"

```

1x Payload as number  
1x Payload as string.

I strongly suspect this is node-red.

---

<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: [29 March 2019 08:47 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/14 "2019-03-29T08:47:14Z")

</div>

I can now reproduce. The missing step to recreating was you had to do a 'modified nodes/flows' type of deploy, rather than full deploy.

---

<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: [29 March 2019 09:18 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/15 "2019-03-29T09:18:22Z")

</div>

That lines up with how I often work. I change a small thing and only deploy node changes (not flow not full).

Now you can recreate it, have you raised an issue or should one of us?

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [29 March 2019 09:24 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/16 "2019-03-29T09:24:01Z")

</div>

That is correct, my apologies. At least this explains the inconsistent behaviour on my end.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [30 March 2019 10:44 UTC](https://discourse.nodered.org/t/mqtt-in-repeated-messages-bug/9520/17 "2019-03-30T10:44:14Z")

</div>

I have raised an issue [#2119](https://github.com/node-red/node-red/issues/2119)

I use some API's that are triggered when the flows are deployed, causing them to complain about `too many requests` - this is why I use the modified flows most of the time.
