Differences between `msg.topic` and `msg._topic` in node MQTT In

I have seen that the MQTT In node generates the _topic property when connected to a local broker.
In my case it has the same content as the conventional topic property. But I have seen somewhere that other people had different content.
I need to understand the difference between these two properties, when their content disagrees and in which cases it is used.
The most I know is that it has some intentionality to detect loops between MQTT In and MQTT Out, but in my tests, these loops keep occurring. Does it avoid them somehow?
I use Node-RED v2.0.6 with Eclipse Mosquitto v2.12 on Ubuntu 20.04.3
Thanks

Hi,

as I mentioned on Twitter, I cannot remember the original reason for adding the _topic property.

Looking at the code, it only gets set if the broker is localhost... which is why I think it was there to help prevent mqtt loops.

However, after doing a complete search of the code base, I cannot find any code in the core nodes that reads the _topic property. The only place it is set is the MQTT In node.

So unless @dceejay can remember something I can't, I suspect it can be removed from the node as an undocumented property that doesn't serve any purpose.

Yes it used to be there as a check to prevent mqtt loops on localhost - I think it used to be set on the in node - and then if it got back to an out node and the topic hadn't been changed it declined to send it. Presumably in all the v5 refactoring it must have got lost/dropped.
(as per your recent Node Con presentation re the history of Node-RED being a message transformation engine for MQTT)

Thank you
Knowing that it is a property that lost its functionality and will be removed in future versions is good enough for me.

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