# MQTT node- device username

**URL:** <https://discourse.nodered.org/t/mqtt-node-device-username/25575>\
**Category:** General\
**Created:** [26 April 2020 23:11 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575 "2020-04-26T23:11:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![e-infotech](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e-infotech/32/20707_2.png) [@e-infotech](https://discourse.nodered.org/u/e-infotech)\
**Post date:** [26 April 2020 23:11 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/1 "2020-04-26T23:11:23Z")

</div>

Hi,  
I created 2 MQTT nodes and I want to send each output to a different device with a different username(token), but the problem is when I change the username, the username of all the previous MQTT nodes will also change!  
How can I fix this issue?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [26 April 2020 23:15 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/2 "2020-04-26T23:15:23Z")

</div>

What do you mean by:

> [@e-infotech](#):
>
> I created 2 MQTT nodes

`MQTT` is a protocol and has 2 nodes in Node-Red. The `IN` and `OUT` nodes.

---

<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:** [26 April 2020 23:16 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/3 "2020-04-26T23:16:42Z")

</div>

Are you wanting to talk to 2 brokers? If so, create a 2nd config node then you can use different credentials.

---

<div class="post-metadata">

**Author:** ![e-infotech](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e-infotech/32/20707_2.png) [@e-infotech](https://discourse.nodered.org/u/e-infotech)\
**Post date:** [26 April 2020 23:20 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/4 "2020-04-26T23:20:07Z")

</div>

![Untitled](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/750c71534d139a342ceb28fc5614909d376d9834.jpeg)

Here is the part of the flow I created 2 nodes

---

<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:** [26 April 2020 23:23 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/5 "2020-04-26T23:23:11Z")

</div>

That doesn't answer my question...

> [@Steve-Mcl](#):
>
> Are you wanting to talk to 2 brokers?

I have a feeling you don't quite get how mqtt fits together.

Typically, you have one broker, all devices publish to it. All devices subscribe to topics of interest.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [26 April 2020 23:32 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/6 "2020-04-26T23:32:28Z")

</div>

It looks more like NR is being used to either bridge or simulate the data of two different devices and they need to each have their own connection to the broker using different authentication credentials.

Sounds perfectly reasonable to me

@e-infotech as Steve mentioned, you need to give each Mqtt node it's own broker config node. At the moment, they are sharing the same config node, so any change applies to the both

Pick one of the nodes and open its edit dialog. In the drop-down select box for the broker, select "add new mqtt-broker", then click the button next to it. That will create a second broker config node for that node to use. Make sure you give each broker config node a name so you can identify them in the select box.

---

<div class="post-metadata">

**Author:** ![e-infotech](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e-infotech/32/20707_2.png) [@e-infotech](https://discourse.nodered.org/u/e-infotech)\
**Post date:** [26 April 2020 23:33 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/7 "2020-04-26T23:33:10Z")

</div>

I know. That node is OUT node actually

---

<div class="post-metadata">

**Author:** ![e-infotech](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e-infotech/32/20707_2.png) [@e-infotech](https://discourse.nodered.org/u/e-infotech)\
**Post date:** [27 April 2020 00:01 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/8 "2020-04-27T00:01:55Z")

</div>

So you mean I have to send the data to broker and then split my data and feed it to my devices or I also can split the data based on the topic and the devices should subscribe to the topics. The problem is that I'd rather use node-red on the other side as well but the one that I have on that side is basic and I think it can't support splitting the data. I'll double check to find a better solution.  
Thank you

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [27 April 2020 07:30 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/9 "2020-04-27T07:30:50Z")

</div>

If both bits of data are going to the same device, then use two different topics to tell them apart. Even the most basic mqtt client knows how to subscribe to a specific topic.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 April 2020 20:58 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/10 "2020-04-27T20:58:40Z")

</div>

I think it would be worth your while spending a little time working through this tutorial on MQTT, then the fundamentals of operation should become clear  
[https://www.hivemq.com/mqtt-essentials/](https://www.hivemq.com/mqtt-essentials/)

---

<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:** [26 June 2020 20:58 UTC](https://discourse.nodered.org/t/mqtt-node-device-username/25575/11 "2020-06-26T20:58:42Z")

</div>

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