MQTT In nodes with overlapping subscriptions emit duplicate messages
Current Behavior
Two mqtt in nodes use the same broker configuration but have overlapping subscriptions:
- one subscribes to
# - one subscribes to
example/remote/action
The nodes are wired to different downstream nodes. When the broker publishes a single arrow_left_click message on the specific topic, the downstream node connected to the wildcard MQTT node receives two identical messages at the same time.
The duplication disappears when the second mqtt in node is removed. This makes it appear that the overlapping subscriptions on the shared broker connection cause one incoming MQTT publication to be emitted twice by an individual mqtt in node, despite the two nodes having separate wires.
Expected Behavior
Each mqtt in node should emit one message for a single matching MQTT publication. Overlapping subscriptions belonging to separate mqtt in nodes should not cause either node's independently wired downstream flow to receive duplicates.
Steps To Reproduce
- Configure two
mqtt innodes to use the same broker configuration. - Set the first topic filter to
#and connect it to a Debug node. - Set the second topic filter to
example/remote/actionand connect it to a different downstream node. - Deploy the flow.
- Publish
arrow_left_clickonce toexample/remote/action. - Observe two identical messages in the Debug node connected only to the
#subscription.
Example flow
[
{
"id": "wildcard-in",
"type": "mqtt in",
"z": "test-flow",
"name": "Wildcard subscription",
"topic": "#",
"qos": "0",
"datatype": "auto",
"broker": "test-broker",
"nl": false,
"rap": false,
"inputs": 0,
"x": 180,
"y": 100,
"wires": [["wildcard-debug"]]
},
{
"id": "wildcard-debug",
"type": "debug",
"z": "test-flow",
"name": "Wildcard output",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 450,
"y": 100,
"wires": []
},
{
"id": "specific-in",
"type": "mqtt in",
"z": "test-flow",
"name": "Specific subscription",
"topic": "example/remote/action",
"qos": "0",
"datatype": "auto",
"broker": "test-broker",
"nl": false,
"rap": false,
"inputs": 0,
"x": 210,
"y": 180,
"wires": [["specific-debug"]]
},
{
"id": "specific-debug",
"type": "debug",
"z": "test-flow",
"name": "Specific output",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 460,
"y": 180,
"wires": []
},
{
"id": "test-broker",
"type": "mqtt-broker",
"name": "Test broker",
"broker": "localhost",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true
}
]Environment
- Node-RED version: 5.0.7
- Node.js version: not captured
- npm version: not captured
- Platform/OS: Node-RED running as an app on Home Assistant OS
- Installation: latest Node-RED app version available through Home Assistant OS
- Browser: not relevant to the runtime behavior
- MQTT protocol version: 3.1.1 (
protocolVersion: 4) - Both MQTT nodes use the same
mqtt-brokerconfiguration node
Source: node-red/node-red