Push MQTT Credentials

#1

Hi, I need connect a mqtt broker as client.
But I want take credentials information from form.
How can I set server cred?.

Can you help me?

0 Likes

#2

I have same problem please help

0 Likes

#3

Can you please expand on the question a little. It isn't quite clear.

0 Likes

#4

I don't want set mqtt server username and password in flow. I have form in dashboard, I want enter MQTT username and password on form. When I click submit connect.

0 Likes

#5

I don't think that will work because the MQTT broker connections are made at Node-RED startup. So by the time anyone could interact via a Dashboard or other web page, the connection is long made.

If you really need to have per-user connections, you will need to set an operating system environment variable before (or as) Node-RED is started and then use that in the MQTT configuration node.

0 Likes

#6

Can't I execute this? with msg payload?

[
{
"id":"2c6873d2.992abc",
"type":"mqtt out",
"z":"eda2a949.74ea98",
"name":"",
"topic":"#",
"qos":"",
"retain":"",
"broker":"407a01e4.6b637",
"x":330,
"y":80,
"wires":[]
},
{
"id":"407a01e4.6b637",
"type":"mqtt-broker",
"z":"",
"broker":"192.168.1.26",
"port":"107",
"clientid":"",
"usetls":false,
"compatmode":true,
"keepalive":"60",
"cleansession":true,
"willTopic":"",
"willQos":"0",
"willPayload":"",
"birthTopic":"",
"birthQos":"0",
"birthPayload":"",
"credentials": {
"user": "Admin",
"password": "iot2018."
}
}
]

0 Likes

#7

That has hard-coded user credentials. That's fine because, as Node-RED starts up, it starts the broker client connection with those credentials. You can't pass credentials dynamically - however, you can sometimes replace fixed text in a node config with {osEnvVarName}. Where osEnvVarName is the name of an operating system environment variable that you set either before Node-RED starts or possibly within the settings.js file (not sure if that works, I think it does).

Either way though, this is set at startup time, not dynamically.

0 Likes

#8

Thanks for reply... :frowning: Can you propose any mqtt dahsboard.

0 Likes

#9

Again, it isn't clear what you mean. What are you trying to achieve?

If you want a "raw" view of what is happening with your MQTT broker(s), try MQTT Spy. It is a Java-based MQTT client tool.

But Node-RED can absolutely be used as a Dashboard for MQTT - just not quite as you envisaged it. The "user" credentials are actually at the device/Node-RED server level rather than the actual user. So set up credentials for each instance of Node-RED that you want to run instead of for each actual user using Node-RED.

0 Likes