MQTT No Longer Works

Hi,
I have been using the same system for years where i receive mqtt Topics to a raspberry pi for a set of gauges, it then has an mqtt out node which sends the Topic to a pc which displays the same gauges, but now all of a sudden the gauges on the pc do not work, the mqtt out node on the pi always says connecting, the ip addresses are static and still the same, any help would be appreciated.
Thanks
Stuart

Hey Stuart.

Ok, could you help with who is what on your network.

The MQTT broker is...... IP address, machine (System), and the machines connected to it.
ie: The one sending the messages and the one receiving them.
So there could be 3 machines.

Things to check:
On the sending machine:
Double click on the MQTT-OUT node and check the configuration.
I know this sounds silly if things are static, but it is really worth double checking them then you can move on with 100% certainty.

P.S.

On the broker:
If a ras-pi/ubuntu type machine.
Check you can send/receive messages.

(You will/may need more stuff installed - basic though)

From the CLI/Terminal:

##  How to send MQTT messages

-h  HOST
-t TOPIC
-m MESSAGE
## comments above.  Commands below.

mosquitto_sub -h 192.168.1.10 -t channel_name

mosquitto_pub -h 192.168.1.10 -t channel_name -m "Hi this is a message"
1 Like

Also, double-check whether you have updated your broker. In the past, I've several times noted that Mosquitto has changed parameters which have broken my installations.

1 Like

Is the MQTT broker on the Pi or elsewhere?
What broker software are you using?
Did you make any changes / operating system updates?

Edit - oops there were no replies when I started typing!

2 Likes

(It's better two people - or more - say the same thing, than no one.)

:wink:

1 Like

HI guys,

I have incoming mqtt node on a rasberry pi ip address 192.168.2.80 and the gauges work perfectly, I then have an mqtt out node which is setup to send to a pc at 192.168.2.66 , at the pc end i have an incoming mqtt node which receives the sent topic and again is sent to a gauge, it all worked for about 8 years but now it does not work, I suspect that updating may have broken it, also I do not use username and password on the mqtt.

node red version pi = 0.18.7
node red version on pc =3.0.2

Thanks
Stuart

Reading what you say:

Is worrying.

The only IP address you should enter is the BROKER's address.

All messages are sent to .... everyone.
If the machine has an MQTT IN node, it gets the message.

I fear there is a problem with things.

(Sorry)

Could you show us:
The IP address of the machine sending the messages - from where the values come.

The IP address of the BROKER.

The IP addresses of any machines that subscribe to the topics. (ie: That you want to show the values on their respective gauges.)

It may also be handy to post screen shots of the MQTT configuration on all the machines.

1 Like

Hi,
I have just tried updating node red on the pi with the script from the website and it says that node red ver 3 does no longer support node js 4, so do i have to update node js first ?

Thanks
Stuart

No offence but this sounds like you have the wrong idea of how MQTT works.
You do not "send" an MQTT message to a specific destination, instead you "publish" the message, and any client can "subscribe" to receive it.

The data is arriving by MQTT? So what broker and topic does the mqtt-in node connect and subscribe to?
Why do you need an mqtt-out node to republish the same data - can't your PC subscribe to the same broker and topic as the Pi and so get the same data?

1 Like

Good grief! On my Pi node.js is version 20.12.1.

If the Raspberry Pi install script won't work because of a very old node.js version, try overriding it by adding --node18 or --node20 to the command (outside the brackets).

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node20

This should update node.js as well as Node-red.

1 Like

Hi,
I am just trying to reinstall now, fingers crossed

Assuming it installs OK, start Node-red and use Manage Palette to apply any updates to your nodes. Then restart NR.

1 Like

ok it got 3 green ticks and then said nodejs is not installed
install node with a red x Bad install node.js is missing - exit

What install command did you use?

1 Like

The one you just told me, the script off the website and then "space" --node20

Hmm.

If you do sudo apt update && sudo apt list --upgradeable, does node.js show up as a potential update?

It might be useful to update the OS before trying any further with the Node-red install script, or else try once more with --node18

1 Like

ok Hit 4 has an ip address for deb.nodesource.com/node_20.x nodistro InRelease

it also says raspbian stretch release does no longer have a release file

If you are running Stretch I suggest buying a new SD card and moving to Bookworm.

Install and update the OS, install Node-red.
Then copy your flows file from the old SD card (it should be /home/pi/.node-red/ flows.json, some older NR versions used flows_hostname.json). There is a credentials file flows_cred.json too which holds for example MQTT broker details.

1 Like

Hi, it sounds like the os is ancient and I need to start over, might buy a new pi and get it up and running first, I will copy my flows first and send it via email, thanks for all your help it was most appreciated

p.s. is there a preferred model of pi or will any work ?

Thanks
Stuart