MQTT input not connecting

#1

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.

image

1 Like
#2
  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'
#3

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

#4

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. 0.0.0.0:1883 means it's listening on all addresses and port 1883 and I'd expect 127.0.0.1 to work properly.

#5

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

#6

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

#7

exactly

image

#8

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
#9

in place of localhost?

#10

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

#11

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

#12

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.

#13

What version of node-red?

#14

I am using version v0.15.3.

#15

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.

#16

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 ;*)

#17

I will do that, thank you

#18

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

#19

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