# Dynamic Settings on MQTT Node

**URL:** <https://discourse.nodered.org/t/dynamic-settings-on-mqtt-node/92082>\
**Category:** General\
**Tags:** mqtt\
**Created:** [30 September 2024 18:44 UTC](https://discourse.nodered.org/t/dynamic-settings-on-mqtt-node/92082 "2024-09-30T18:44:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 September 2024 19:06 UTC](https://discourse.nodered.org/t/dynamic-settings-on-mqtt-node/92082/2 "2024-09-30T19:06:19Z")

</div>

You need to send msg.action and msg.broker with broker, port ,username and password to connect. To disconnect you just need to send msg.action  
e.g.

```auto
[{"id":"989ce477843d6ccb","type":"inject","z":"d1395164b4eec73e","name":"connect","props":[{"p":"action","v":"connect","vt":"str"},{"p":"broker","v":"{\"broker\":\"192.168.1.25\",\"port\":1883,\"password\":\"\",\"username\":\"\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":370,"y":7640,"wires":[["a8750ccc1e9f1a78","43c3fe97cfaf9f04"]]},{"id":"a8750ccc1e9f1a78","type":"mqtt out","z":"d1395164b4eec73e","name":"","topic":"","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e8ba3ef5.22f4a8","x":610,"y":7640,"wires":[]},{"id":"43c3fe97cfaf9f04","type":"debug","z":"d1395164b4eec73e","name":"debug 17","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":7720,"wires":[]},{"id":"c67446f710eaae5a","type":"inject","z":"d1395164b4eec73e","name":"disconnect","props":[{"p":"action","v":"disconnect","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":340,"y":7700,"wires":[["a8750ccc1e9f1a78","43c3fe97cfaf9f04"]]},{"id":"e8ba3ef5.22f4a8","type":"mqtt-broker","name":"testb","broker":"192.168.1.25","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"5","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

```

Add you broker and user and password in the inject node.

Here is another example flow that demonstrates most dynamic mqtt features [Dynamic MQTT node's "actions-\>connect" guidance needed - #2 by Steve-Mcl](https://discourse.nodered.org/t/dynamic-mqtt-nodes-actions-connect-guidance-needed/58878/2)

---

_[View the full topic](https://discourse.nodered.org/t/dynamic-settings-on-mqtt-node/92082)._
