MQTT node output ghost topics

I have 11 flows in my node red with a number of MQTT outputs. Looking at the outputs in MQTT explorer I have four topics, labeled Random1, Random2, Random3, Random4 that always output a 0. My problem is that I don't have any MQTT nodes outputting that information now. At one time I did set these up but decided to go a different direction but these outputs remain. I have gone through every flow, every node, looked at every item on the side bar but cannot find where this information is coming from. I have rebooted the pi several times thinking it was something transient but the outputs survive the reboot and when the pi comes back up the information is there. I can work around this problem but curious to know what it could be. I don't think posting flows would help since I can't find this in any flow.
Thoughts anyone?

Do they ever change value when you watch or is it that they appear once when you subscribe to them? If the latter then it means that you published them as Retained topics which means that the MQTT server remembers the value even if you never publish to it again. If you use mosquitto then you can clear these out using the command
mosquitto_pub -t <topic> -r -n
or in your particular case
mosquitto_pub -t Random1 -r -n

They never change value, ran the commands you suggested to no effect. The values do seem to be refreshing as the values flash every second or so.

If you use the command line to get them you can confirm whether they are being published to
mosqitto_sub -t Random1
You will get a new line each time a value is published. If you do see new values then what happens if you stop node-red whilst leaving the mosquitto_sub command running? If they stop then start node red again and disable tabs in the editor till it stops, then you know where to look.

I disabled every tab in node red and the topics are still there. Interestingly there are two others that are still there also although they don't give me any trouble.

Was that using mosquitto_sub?
What if you stop node-red? Do you still see additional lines of output in mosquitto_sub?

I stopped node red using 'node-red stop' I continued to see the output in mosquitto. I disabled every tab and rebooted and still see the topics in MQTT explorer.

Am I to the point of uninstalling then reinstall mosquitto?

So I uninstalled using 'sudo apt-get purge --remove mosquitto*' then reinstalled. When I reinstalled the topics came back. Didn't remove any directories when I did it though. Late here , time for some shut eye. I will tackle this again later, thanks for your help Colin

have you tried restarting MQTT explorer and disconnecting/reconnecting with a fresh client id? They might be leftovers from that time that you were experimenting with them, and as long as the explorer is open they will stay in view.

Have you confirmed that node-red is definitely stopped? Check you can't connect from the browser. If you still see repeated messages appearing in mosquitto_sub when node-red is stopped then obviously it is not node-red publishing the data. Could it be another device publishing it? The next thing to look at is the mosquitto log, there you should be able to see which device is connected. On a linux system that will probably be in /var/log/mosquitto/mosquitto.log.

1 Like

Do you have anyother devices (Wemos etc) that are on your network that might be publishing?

To answer zenofmud there was absolutely no chance it was another device on the network. So, of course that is what it turned out to be. My development pi had the flow on it that I thought I had deleted. But there were so many tabs it turns out there was another one way in the back that I missed. Deleted that flow and everything works normally.
Thanks all for the help

3 Likes

I took this as a good time to clean up my development pi.

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