I am experimenting with Dynamic MQTT configuration, and have a couple of problems. I will ask about them separately to avoid confusing threads.
I can't get it to work using msg.broker.url
to specify the broker. if I setup msg.broker
to contain broker
and port
separately then it works. I assume that the url should be of the form "localhost:1883". This flow demonstrates the problem. I am using node-red 3.0.2 with nodejs 16.
[{"id":"518225cfb1b5fb8c","type":"inject","z":"bdd7be38.d3b55","name":"Disconnect","props":[{"p":"action","v":"disconnect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":3120,"wires":[["02a1909dcc82a87e"]]},{"id":"59aa2f05e0a8c24c","type":"inject","z":"bdd7be38.d3b55","name":"Connect via broker, port","props":[{"p":"action","v":"connect","vt":"str"},{"p":"broker","v":"{\"broker\":\"localhost\",\"port\":\"1883\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":3200,"wires":[["02a1909dcc82a87e"]]},{"id":"02a1909dcc82a87e","type":"mqtt in","z":"bdd7be38.d3b55","name":"","topic":"","qos":"0","datatype":"auto-detect","broker":"f009e0d5c98277d8","nl":false,"rap":true,"rh":0,"inputs":1,"x":350,"y":3140,"wires":[[]]},{"id":"0be15fef04b453e2","type":"inject","z":"bdd7be38.d3b55","name":"Connect via url","props":[{"p":"action","v":"connect","vt":"str"},{"p":"broker","v":"{\"url\": \"localhost:1883\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":160,"y":3160,"wires":[["02a1909dcc82a87e"]]},{"id":"f009e0d5c98277d8","type":"mqtt-broker","name":"Dynamic","broker":"0.0.0.0","port":"0","clientid":"","autoConnect":false,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]