# Setting mqtt out node properties from json string

**URL:** <https://discourse.nodered.org/t/setting-mqtt-out-node-properties-from-json-string/66856>\
**Category:** General\
**Created:** [24 August 2022 13:06 UTC](https://discourse.nodered.org/t/setting-mqtt-out-node-properties-from-json-string/66856 "2022-08-24T13:06:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeyMikey](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@MikeyMikey](https://discourse.nodered.org/u/MikeyMikey)\
**Post date:** [24 August 2022 13:06 UTC](https://discourse.nodered.org/t/setting-mqtt-out-node-properties-from-json-string/66856/1 "2022-08-24T13:06:51Z")

</div>

Hi,  
Is it possible to set the properties of a mqtt out node e.g. server name, port, protocol, username, password etc from a function in node red? Along the same line as msg.qos=2 and msg.retain=false and msg.topic="my/topic"

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 August 2022 13:09 UTC](https://discourse.nodered.org/t/setting-mqtt-out-node-properties-from-json-string/66856/2 "2022-08-24T13:09:57Z")

</div>

> [@MikeyMikey](#):
>
> Is it possible to set the properties of a mqtt out node e.g. server name, port, protocol, username, password etc from a function in node red

yes.

From the built in help...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/44baf94e60f227c8d34d47bc3d69cdd8a9a983b0.png)

Demo...

> [@Dynamic MQTT node's "actions-\>connect" guidance needed](https://discourse.nodered.org/t/dynamic-mqtt-nodes-actions-connect-guidance-needed/58878/2):
>
> The dynamic connection does not overwrite fields. It simply connects to the broker specified in the msg you send. You just add a broker (with any settings you like) and set it to NOT auto connect [image] then you send the appropriate msg to set up and connect. Here is a working demo... [mqtt-dyn] [{"id":"a7f43be0a40d080b","type":"mqtt out","z":"8afdb9e0485c9da7","name":"mqtt out","topic":"","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","…

---

<div class="post-metadata">

**Author:** ![MikeyMikey](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@MikeyMikey](https://discourse.nodered.org/u/MikeyMikey)\
**Post date:** [25 August 2022 10:58 UTC](https://discourse.nodered.org/t/setting-mqtt-out-node-properties-from-json-string/66856/3 "2022-08-25T10:58:52Z")

</div>

Thanks Steve-Mcl, much appreciated.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 October 2022 10:59 UTC](https://discourse.nodered.org/t/setting-mqtt-out-node-properties-from-json-string/66856/4 "2022-10-24T10:59:27Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
