# How can I find out \*who\* is publishing a message in MQTT?

**URL:** <https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732>\
**Category:** General\
**Created:** [3 October 2023 02:21 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732 "2023-10-03T02:21:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 October 2023 02:21 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/1 "2023-10-03T02:21:37Z")

</div>

I have MQTT explorer installed and running.

I am getting 3 message being published every..... so often, that are no longer needed.

Their TOPICs are `STATUS/(device name)`  
They aren't retained and if I delete them, they come back fairly quickly.

I can't find a node (`MQTT OUT`) with that in the `topic` field.  
So the `device name` is set before it gets to the node.  
(And probably the whole topic.)

Yes, not really Node-red's problem.

I'm just looking for help to find _who_ is sending the messages.

## Update:

This is a screen shot - just to show you.

 ![Screenshot from 2023-10-03 13-55-34](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/b/7bab6a45a11b4335c601a86ed6fbcdbdb7a4a669.png)  
(red areas)

So I have 3 messages. Topics: STATUS/BedPi, STATUS/TelePi and STATUS/TimePi  
The value changes - up and down - with each message.

So, thought 1:  
`STATUS/BedPi` shouldn't be hard to find if I search for it in a `MQTT OUT` node.  
All 3 machines searched. NOTHING!

Ok, not to be outdone:  
Search for `STATUS` in `MQTT OUT` nodes and back track from there.

Nothing exciting there either.

I guess last option is to search for all _topic empty_ `MQTT OUT` nodes and back track from them.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [3 October 2023 03:51 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/2 "2023-10-03T03:51:19Z")

</div>

> [@Trying\_to\_learn](#):
>
> STATUS/BedPi

Open the search in flows and search for the topic, you should see all nodes with that content

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9c204ca9a98430d0f7dc6dbacf1321a718bd6e01.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 October 2023 04:00 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/3 "2023-10-03T04:00:19Z")

</div>

Alas I seem to be missing something there.

Here is an example in pictures.

![Screenshot from 2023-10-03 14-56-03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3d880e78d3c5570e94d9a253692ffe15dde0211c.png)

If I add `BedPi` to it (being it I am on that machine) I get no results.

So....

It has to be an OUT node.

2 visible.

 ![Screenshot from 2023-10-03 14-56-24](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/2/32302c5d37f9e6c8225d3c7ca641d00144082050.png)

This isn't it. It only sends stuff if an `IFF` message is received. There aren't any going around.

And the last/second one:

 ![Screenshot from 2023-10-03 14-56-46](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6fba15c4a8b460226f66bae04eff1bed9a29c0a6.png)

Wrong extra stuff on the `topic`. ☹  
I tried the other thing I mentioned.

No luck there either.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [3 October 2023 05:28 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/4 "2023-10-03T05:28:46Z")

</div>

You sure it is from Node-RED it is published? I remember you also had some Pythonn scripts, could it be one of those?? Or some other sw

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 October 2023 05:32 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/5 "2023-10-03T05:32:14Z")

</div>

Thanks.

No, not from python.

The _old_ structure is the message was sent with the device's name to identify who sent it.

I've re-written the code and that/those message are no longer needed.

It isn't important to leave it, but to try and be tidy.

I'm trying to remove it from the echo system.

the python scripts were to control NeoPixel LEDs and send messages to a local LCD on the same machine. (That machine isn't online now anyway.)

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [3 October 2023 05:55 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/6 "2023-10-03T05:55:14Z")

</div>

It will not be simple to figure out if you have a complex setup with many publishers involved, you will in that case have to manually go through all

See also this:

> <https://stackoverflow.com/questions/48582792/how-to-make-mosquitto-sub-print-ip-address-of-publisher-of-particular-message>

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 October 2023 05:57 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/7 "2023-10-03T05:57:07Z")

</div>

Thanks.

I think I will have to find some time and disable flows and see if/when it stops.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [3 October 2023 05:57 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/8 "2023-10-03T05:57:12Z")

</div>

If you know it is coming from a Node-RED instance, one way could be to search each flow file for the topics you are looking for. Use a text editor and do the search

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 October 2023 05:58 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/9 "2023-10-03T05:58:50Z")

</div>

But I fear the topic is not really defined.

It is constructed.

eg:  
`STATUS` + global.get("myDevicename")

But if there are any spaces between the `STATUS` the `+` and the `global.get()` will make it harder.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [3 October 2023 06:01 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/10 "2023-10-03T06:01:50Z")

</div>

How many search hits do you get for "myDevicename"?

Presumably one hit is where msg.topic is constructed for mqtt, either a function or a change node.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 October 2023 06:06 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/11 "2023-10-03T06:06:56Z")

</div>

Well, this is the result:

![Screenshot from 2023-10-03 17-03-04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/7/b70ad0766de52e36e6dbba39cfdf6e4a14292a54.png)

So 14 isn't impossible.

BUT - ooooh!

After a bit of digging....

I think I found it.

Alas it wasn't what I thought it was. ☹  
But thanks for suggesting it @jbudd .

I had done it but hadn't dug this deep.

Thanks.

Alas it is something else so I can't delete it.

---

<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:** [3 October 2023 07:33 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/12 "2023-10-03T07:33:39Z")

</div>

If someone _REALLY_ did need to add traceability to your publishers, then MQTT V5 can help here.

You can add extra info in the publish packet WITHOUT affecting the original payload.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/5/b520e670005e1f42a810cfd514bff5cd33f7f14f.png)

You can even supply the userProperties via the `msg`

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/466fd35ae29bc39f00cc5b953194a01c6a8ee487.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 October 2023 07:37 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/13 "2023-10-03T07:37:39Z")

</div>

Thanks.

That's good to know.

Honestly though I guess it was me who didn't name the `topic` as well a I should.  
But I guess that is all part of actually learning.

I've re-written/structured a fairly big part of the working of my 3 main machines and their comms of what is going on with things.

Probably about 1 full day of _man hours_ work.

And ITMT a fairly serious bit of Arduino programming done on another project.  
Structures crossed up and mistaken between the languages.

How easy is it to install?  
(Just since we are here)

---

<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:** [3 October 2023 07:40 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/14 "2023-10-03T07:40:18Z")

</div>

> [@Trying\_to\_learn](#):
>
> How easy is it to install?

you already have MQTT v5. Just select the option on the broker config node.

_(assuming you are using a recent enough broker like Mosquitto v2+ which supports V5)_

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 October 2023 07:41 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/15 "2023-10-03T07:41:57Z")

</div>

~~No, 3.11 ☹~~

Ah, Ok, select Version 5 in the drop down.

Thanks.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [3 October 2023 07:57 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/16 "2023-10-03T07:57:02Z")

</div>

@Steve-Mcl without straying too far off topic... should users be generally using v5 by default now, even if they are not using its advanced features?

...and how does v5 affect external devices, such as Shellie's, etc.

---

<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:** [3 October 2023 08:10 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/17 "2023-10-03T08:10:23Z")

</div>

> [@Paul-Reed](#):
>
> should users be generally using v5 by default now

It has other benefits like richer error reporting (so when something goes skewwhiff there is a chance you know why). Also, when you sub to multiple same topic, you dont start getting mutiple subs where you expected 1. It is also faster in cases where topic aliases are used. However, I dont think 3.11 is going anywhere just yet.

> [@Paul-Reed](#):
>
> ...and how does v5 affect external devices, such as Shellie's, etc.

Most (if not all) brokers that support v5, also supports 3.11, so if the shellies only support 3.11, they can still play alongside your v5 connected Node-REDs

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [3 October 2023 10:46 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/18 "2023-10-03T10:46:59Z")

</div>

> [@Steve-Mcl](#):
>
> If someone _REALLY_ did need to add traceability to your publishers, then MQTT V5 can help here.

I really must update all of my flows to use this!

Though sadly, MQTT Explorer has never been updated to work with MQTT v5 so it would be hard to easily see the extra data.

* * *

Previously, I've always got round this issue by making sure that the output topic also has sub-topics that say where and when the topic update came from.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/4/b47bffd413ff0d477df5ed1800eac06fb505925a.png)

---

<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:** [3 October 2023 11:11 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/19 "2023-10-03T11:11:32Z")

</div>

> [@TotallyInformation](#):
>
> Though sadly, MQTT Explorer has never been updated to work with MQTT v5 so it would be hard to easily see the extra data.

I still use MQTT explorer but my other go-to is improving lots (has MQTT v5 as well): [https://mqttx.app/features](https://mqttx.app/features)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [3 October 2023 13:43 UTC](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732/20 "2023-10-03T13:43:44Z")

</div>

Yes, I've just tried that. But it has a major flaw - it does not show a topic hierarchy like Explorer does which is a pain if you are trying to oversea your whole broker - this is what Explorer excels at. So you can't really monitor anything that has a high volume of updates very easily.

Looks like I need to revisit some ideas I had previously about creating something in Node-RED. 🙂

[Next page](https://discourse.nodered.org/t/how-can-i-find-out-who-is-publishing-a-message-in-mqtt/81732.md?page=2)
