MQTT node - messages received twice!?

As I noted in my response of Nov 16th,

Where are you running node-red? If that is not on the ESP then you could install mosquitto on the node red server rather than on the ESP.

Otherwise you may just have to put up with this issue. One workaround, I guess, would be to avoid using the # specification and instead have multiple MQTT nodes in parallel, one for each topic.

Correct, I'm using non-overlapping subscriptions on the MQTT nodes as a workaround.

Please try this test. Add two inject nodes and connect them to a single mqtt-out node.
In both inject nodes, set msg topic to 'events/ESP8266MQTTBroker/RAM'

In inject1 set the payload to 'from inject 1'
In inject2 set the payload to 'from inject 2'

Deploy and press inject 1, do you get two msgs from each mqtt-in node?
press inject 2, do you get two msgs from each mqtt-in node?

One issue you have is that every msg sent with a topic of 'events/ESP8266MQTTBroker/anything-else' will be received by both mqtt-in nodes because of the way you are subscribing to the topics.

You miget be beter off to have one mqtt-in node subscribing to 'events/#' and the output of that node going to a switch node that checks to see if msg topic contains 'events/ESP8266MQTTBroker' and has an otherwise condition to split the msgs to the two outputs based on the contents of the topic.

1 Like

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