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

**URL:** <https://discourse.nodered.org/t/differences-between-msg-topic-and-msg-topic-in-node-mqtt-in/52832>\
**Category:** General\
**Created:** [27 October 2021 15:04 UTC](https://discourse.nodered.org/t/differences-between-msg-topic-and-msg-topic-in-node-mqtt-in/52832 "2021-10-27T15:04:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwendenarmo](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kwendenarmo](https://discourse.nodered.org/u/kwendenarmo)\
**Post date:** [27 October 2021 15:04 UTC](https://discourse.nodered.org/t/differences-between-msg-topic-and-msg-topic-in-node-mqtt-in/52832/1 "2021-10-27T15:04:13Z")

</div>

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

---

<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:** [27 October 2021 16:17 UTC](https://discourse.nodered.org/t/differences-between-msg-topic-and-msg-topic-in-node-mqtt-in/52832/2 "2021-10-27T16:17:48Z")

</div>

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.

---

<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:** [27 October 2021 17:00 UTC](https://discourse.nodered.org/t/differences-between-msg-topic-and-msg-topic-in-node-mqtt-in/52832/3 "2021-10-27T17:00:17Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![kwendenarmo](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kwendenarmo](https://discourse.nodered.org/u/kwendenarmo)\
**Post date:** [27 October 2021 17:07 UTC](https://discourse.nodered.org/t/differences-between-msg-topic-and-msg-topic-in-node-mqtt-in/52832/4 "2021-10-27T17:07:00Z")

</div>

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

---

<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:** [10 November 2021 17:07 UTC](https://discourse.nodered.org/t/differences-between-msg-topic-and-msg-topic-in-node-mqtt-in/52832/5 "2021-11-10T17:07:10Z")

</div>

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