MQTT input not connecting

I have been having an issue getting the MQTT input block to connect to my emonPi (raspberry pi system by openenergymonitor). When I connect to the emonPi via SSH through putty, I am able to view all of the MQTT messages. This to me means that everything is working fine on that end, but I could be wrong. When I try to connect the pi to nodered using the mqtt input, I have not been able to connect. My first thought is is there password authentication required before accessing the info passed by MQTT? Thank you for your help.


1 Like
  1. how are you verifing the MQTT messages?
  2. is node-red running on the same pi as mqtt is running? If not, you need to provide the ip address in place of 'localhost'

node-red is running on the same pi as mqtt is running

If I understand you correctly, when you run the command from the command line (something like mosquitto_sub -t ...) it returns the data being sent (old data won't be there unless it was sent with retain).

Can you run, on the pi, the following command?:

netstat -nat | grep LISTEN | grep 1883

That should come back with the address the MQTT server is listening on. means it's listening on all addresses and port 1883 and I'd expect to work properly.

Might be worth playing around with the address - try and/or the actual IP address of the Pi

You didn't answer @zenofmud's first question.
Are you running mosquitto_sub on the pi to verify the MQTT messages are getting through?



Sorry I forgot to answer that question. I am running

$ mosquitto_sub -v -u 'emonpi' -P 'password' -t 'emon/emonpi/power1'

and getting back:

emon/emonpi/power1 4550
emon/emonpi/power1 4516
emon/emonpi/power1 4558
emon/emonpi/power1 4553

in place of localhost?

Click on the pen next to the broker address in the mqtt node and you can setup the credentials there.

If it is giving the message, "Deploy Failed. Not Authorized" that must mean mqtt doesn't like my username or password, right?

If you mean the MQTT user/pwd setup in the MQTT config node then no, I don't think so, that would just fail to connect to MQTT, the error is saying you cannot deploy the flow itself. I am not sure how that would happen. Have you got user/pwd configured for node red itself? If not then I suggest doing a full refresh of the browser and check you can deploy a minor change, if that is ok then try the MQTT config again.

What version of node-red?

I am using version v0.15.3.

When I refreshed it asked me for Node-RED credentials again, and then when I went to test mqtt input it was connected. I'm not really sure what happened but thank you for the help.

E. - that is a very old version of node-red. If you are able to run the upgrade scripts, there are many enhancements that you may enjoy. Just be sure to make a copy of your sdcard first ;*)

I will do that, thank you

did you set up the Node-Red MQTT entry with the user and password info under the security section of the node?

1 Like

I did after @Colin mentioned doing so, issue resolved now.