# Use NodeRED as MQTT Bridge

**URL:** <https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162>\
**Category:** General\
**Tags:** mqtt\
**Created:** [5 March 2024 14:44 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162 "2024-03-05T14:44:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![omem](https://avatars.discourse-cdn.com/v4/letter/o/58956e/32.png) [@omem](https://discourse.nodered.org/u/omem)\
**Post date:** [5 March 2024 14:44 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/1 "2024-03-05T14:44:35Z")

</div>

Im trying to forward from MQTT in to MQTT out connection  
They on diffrent MQTT connections, (the input from hiveMQ broker and the the output is for AWS IoT core)  
why it is dosent work for me  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a82517bf2b08243875a3bd4f3e247c257bae5e01.png)  
I also tried to add aFunction which return msg.payload but still

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

Thanks

---

<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:** [5 March 2024 14:52 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/2 "2024-03-05T14:52:52Z")

</div>

> [@omem](#):
>
> why it is dosent work for me

No idea. It should work. Have you configured 2 separate configs (show us the config dropdown in one of your MQTT nodes)

Have you seen any messages arrive? (hint: add a debug node after MQTTsub\_sensor)

Have you got the configs correctly configured and pointing at the correct brokers?

> [@omem](#):
>
> I also tried to add aFunction which return msg.payload but still

still what?

Try adding a debug node after the function - do you see MQTT values?

---

<div class="post-metadata">

**Author:** ![omem](https://avatars.discourse-cdn.com/v4/letter/o/58956e/32.png) [@omem](https://discourse.nodered.org/u/omem)\
**Post date:** [5 March 2024 15:11 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/3 "2024-03-05T15:11:30Z")

</div>

Hi, yes I added debug after the MQTTsub\_sensor the message is arriving  
and I get he messages from the timestamp in the AWS

the message that arrived in the MQTTsub\_sensor is a JSON format message so it is show that as an object, maybe that cause the problem ?

---

<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:** [5 March 2024 15:17 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/4 "2024-03-05T15:17:52Z")

</div>

> [@omem](#):
>
> maybe that cause the problem

But you have not said what the problem is!

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [5 March 2024 15:19 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/5 "2024-03-05T15:19:16Z")

</div>

> [@omem](#):
>
> a JSON format message so it is show that as an object, maybe that cause the problem

MQTT is perfectly happy with JSON formatted payloads.

Are you passing msg.topic to MQTTpub\_aws or is the topic set in the node config?

---

<div class="post-metadata">

**Author:** ![omem](https://avatars.discourse-cdn.com/v4/letter/o/58956e/32.png) [@omem](https://discourse.nodered.org/u/omem)\
**Post date:** [5 March 2024 15:20 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/6 "2024-03-05T15:20:59Z")

</div>

the problem is that Im not get the message from the MQTTsub\_sensor in the AWS IoT core  
but I get the message from the timestamp node  
so the probelm is not the configuration in the MQTTpub\_aws

---

<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:** [5 March 2024 15:23 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/7 "2024-03-05T15:23:22Z")

</div>

Unless the AWS broker has the means to reject the JSON data (which BTW is sent as a string) then all I can think is the `topic` is NOT set in the AWS node and your values are going to the topic set from the incoming data of the MQTT-IN node

It is hard to tell as you have not shared a flow or shown us how you have configured the nodes.

---

<div class="post-metadata">

**Author:** ![omem](https://avatars.discourse-cdn.com/v4/letter/o/58956e/32.png) [@omem](https://discourse.nodered.org/u/omem)\
**Post date:** [5 March 2024 15:33 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/8 "2024-03-05T15:33:03Z")

</div>

I set topic in both mqtt nodes, but they are different (becuase there is different mqtt brokers and different systems)

when I change that the will have the same topic it is work  
it is sound strange for me because I want to use NodeRED for listening for few different systems with different MQTT brokers

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 March 2024 15:40 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/9 "2024-03-05T15:40:57Z")

</div>

What is the size of the JSON string you are sending? Does AWS MQTT have a size limit?

---

<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:** [5 March 2024 16:07 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/10 "2024-03-05T16:07:55Z")

</div>

> [@omem](#):
>
> I set topic in both mqtt nodes, but they are different (becuase there is different mqtt brokers and different systems)  
> when I change that the will have the same topic it is work

Please, with the working version, select the two mqtt nodes and use the Export feature to copy to clipboard and paste that here, using the `</>` button at the top of the forum entry window when pasting it in.  
Then do the same with it configured with the different topics. Then we can see exactly what you are doing.

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [6 March 2024 18:21 UTC](https://discourse.nodered.org/t/use-nodered-as-mqtt-bridge/86162/11 "2024-03-06T18:21:07Z")

</div>

What is the topic where the payload will be published ?  
AWS "fake" MQTT implementation is not MQTT compliant... It can only support 7 levels of topics.  
Which is according to AWS a "good practice" see :

> **[MQTT design best practices - Designing MQTT Topics for AWS IoT Core](https://docs.aws.amazon.com/whitepapers/latest/designing-mqtt-topics-aws-iot-core/mqtt-design-best-practices.html)**
>
> Although there are numerous combinations of IoT communication patterns that share common approaches, there are several best practices that apply to any message pattern irrespective of how a device is publishing or receiving a message. This section...

There might well be other limitations that AWS may explain as good practices 😉
