# Insufficient dynamic mqtt documentation?

**URL:** https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458
**Category:** General
**Created:** [17 October 2024 11:32 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458 "2024-10-17T11:32:25Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [17 October 2024 11:32 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/1 "2024-10-17T11:32:25Z")

</div>

Node red doc for mqtt in (dynamic) is somewhat lackluster. Trying this for the first time, I see what's presented, but not sure what "broker" is (type?), compared url and port. Also I don't see anywhere to specify client id. Luckily, thanks to amazing community, there are some existing discussions which shed some light. Like this: [Dynamic MQTT node's "actions-\>connect" guidance needed](https://discourse.nodered.org/t/dynamic-mqtt-nodes-actions-connect-guidance-needed/58878)

Wouldn't it be nice to update the documentation to include this info readily available?

I'm also not sure about connect vs subscribe, do I need to do both (first connect, then subscribe?) or choose one of them?

I find dynamic config is much smoother compared to hardcoded values, because it is how "everything" else works (like http for example) and it allows for .env variables to store secrets outside node red.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [17 October 2024 11:46 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/2 "2024-10-17T11:46:58Z")

</div>

You should take a read of this great tutorial of MQTT:

> **[MQTT Essentials - All Core Concepts Explained](https://www.hivemq.com/mqtt/)**
>
> MQTT Essentials: Learn the core concepts of MQTT, its features and other essential information about the protocol for IoT and IIoT.

to get a handle on the terminology used.

What do you think should be added to the HELP for the MQTT nodes? Show what you think would make the current explanation better. If people agree you could even create a PR to update the help.

---

<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: [17 October 2024 11:51 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/3 "2024-10-17T11:51:39Z")

</div>

Broker would be the IP of the broker (should possibly say server as in config title).  
But there are many topics on this in the forum, here is one from the nodes maintainer that has many examples [Dynamic MQTT LWT birth, Close & Will Property - #2 by Steve-Mcl](https://discourse.nodered.org/t/dynamic-mqtt-lwt-birth-close-will-property/58951/2)  
I am surprised these examples have not bee added to the node-red library import examples for the node.

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [17 October 2024 11:59 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/4 "2024-10-17T11:59:32Z")

</div>

I want to set the connection credentials in function node. That requires "dynamic settings" to get input. Then the doc says the following:

> broker broker  
> For the "connect" action, this property can override any of the individual broker configuration settings, including:
> 
> ```
> broker
> port
> url - overrides broker/port to provide a complete connection url
> username
> password
> 
> If this property is set and the broker is already connected an error will be logged unless it has the force property set - in which case it will disconnect from the broker, apply the new settings and reconnect.
> 
> ```

What is broker? Where is clientId?

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [17 October 2024 12:01 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/5 "2024-10-17T12:01:14Z")

</div>

Thanks! Yeah the only official examples I found was the simplified version with hardcoded connection in config node.

Broker is IP of broker? How does that compare to URL then? Cause I normally enter IP into url fields, ref http.

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [17 October 2024 12:06 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/6 "2024-10-17T12:06:27Z")

</div>

MQTT in gives linting error if not setting a broker config node. I don't want broker config node, as this is set dynamically. Unless broker config node can take dynamic env variables (which as far as I can see, it cannot).

If I add a dummy broker config node, it too gives linting error if not setting server (blank). So I add dummy server/url value to the dummy config node.

Without anywhere to dynamically set client ID, I'm not getting connected.

When setting correct client id to the dummy config node, I get connected. Why is "dynamic mode" not supporting dynamic client id?

---

<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: [17 October 2024 12:14 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/7 "2024-10-17T12:14:12Z")

</div>

> [@ThingsTinkerer](#):
>
> Broker is IP of broker? How does that compare to URL then?

URl would be a ip or domain with port, and would override broker and port.  
e.g  
192.168.1.20:1883

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [17 October 2024 12:19 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/8 "2024-10-17T12:19:39Z")

</div>

Got it thanks! Now onto client id... 🤔

Also struggling with getting the auto-connect feature of static config applied to dynamic config. Only way I found so far is to add status node, listen and filter status changes from mqtt-in and then send it to function node before mqtt-in node. A bit too messy and fragile for my liking.

"force" (boolean) arg in broker seems interesting and useful. Is this documented anywhere? I accidentally stumbled upon it in a discussion, so found it by chance. Would be great to have this in the HELP section!

---

<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: [17 October 2024 12:30 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/9 "2024-10-17T12:30:07Z")

</div>

> [@ThingsTinkerer](#):
>
> "force" (boolean) arg in broker seems interesting and useful. Is this documented anywhere?

It is mentioned at the bottom of the sidebar help text

> If this property is set and the broker is already connected an error will be logged unless it has the `force` property set - in which case it will disconnect from the broker, apply the new settings and reconnect.

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [17 October 2024 12:34 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/10 "2024-10-17T12:34:31Z")

</div>

Good find! Unfortunately node red hijacks browser ctrl+f to search doc, so I'm struggling a bit to change muscle-memory to use F3 instead.

I assume "dynamic" config can't dynamically set client id?

---

<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: [17 October 2024 12:37 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/11 "2024-10-17T12:37:35Z")

</div>

> [@ThingsTinkerer](#):
>
> assume "dynamic" config can't dynamically set client id?

Asked 6 days ago [Can the MQTT ClientID be set dynamically?](https://discourse.nodered.org/t/can-the-mqtt-clientid-be-set-dynamically/92312/1)

---

<div class="post-metadata">

### Author: ![ThingsTinkerer](https://avatars.discourse-cdn.com/v4/letter/t/91b2a8/32.png) [@ThingsTinkerer](https://discourse.nodered.org/u/ThingsTinkerer)
#### Post date: [17 October 2024 12:45 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/12 "2024-10-17T12:45:50Z")

</div>

Thanks, somehow that didn't show up when I made this topic and also failed at finding it when searching. Would be wonderful to have all these "secret" attributes documented in HELP section 🤩 But for me, I get what I need now with that great community example.

---

<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: [31 October 2024 12:46 UTC](https://discourse.nodered.org/t/insufficient-dynamic-mqtt-documentation/92458/13 "2024-10-31T12:46:08Z")

</div>

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