# I can't publish data from node-red

**URL:** <https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780>\
**Category:** General\
**Created:** [17 May 2021 12:22 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780 "2021-05-17T12:22:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaleaura](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yaleaura](https://discourse.nodered.org/u/Yaleaura)\
**Post date:** [17 May 2021 12:22 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/1 "2021-05-17T12:22:05Z")

</div>

My device cannot receive the data.Here are the pictures of my settings

 ![cap1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/b/2bedcc2593fd1d69b7b12e2f3affd2f6dc33d951.png)  
 ![cap2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/c/fce6c9fbf3d2d4645f4dbd1d11bfdba876283dbc.png)

---

<div class="post-metadata">

**Author:** ![Yaleaura](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yaleaura](https://discourse.nodered.org/u/Yaleaura)\
**Post date:** [17 May 2021 12:23 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/2 "2021-05-17T12:23:24Z")

</div>

![Cap3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d221e389fba238d1f4b80fb671f07258b7d3996.png)

---

<div class="post-metadata">

**Author:** ![Simon01011](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Simon01011](https://discourse.nodered.org/u/Simon01011)\
**Post date:** [17 May 2021 12:23 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/3 "2021-05-17T12:23:56Z")

</div>

What does the debug node show?

---

<div class="post-metadata">

**Author:** ![Yaleaura](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yaleaura](https://discourse.nodered.org/u/Yaleaura)\
**Post date:** [17 May 2021 12:30 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/4 "2021-05-17T12:30:42Z")

</div>

this  
 ![Cap4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e68d62e3c692d2354c2a56cba63fb3125170c620.png)

---

<div class="post-metadata">

**Author:** ![Simon01011](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Simon01011](https://discourse.nodered.org/u/Simon01011)\
**Post date:** [17 May 2021 12:40 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/5 "2021-05-17T12:40:49Z")

</div>

So the inject node works. Might be the pushData node is not correctly configured... maybe wrong mqtt 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:** [17 May 2021 12:50 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/6 "2021-05-17T12:50:07Z")

</div>

Add an MQTT In node configured with that topic, connected to a debug node, and make sure that it sees the data. Assuming that it does then it is not node-red that is the problem.

Where is your MQTT broker, what broker is it? Do you know that the device has connected to the broker?

If you are using mosquitto V2 then you need to tell it to allow connections from remote devices.

---

<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:** [17 May 2021 12:57 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/7 "2021-05-17T12:57:43Z")

</div>

Why do you have spaces in the property names? Maybe your device is receiving the data but ignoring it due to badly formed data?

---

<div class="post-metadata">

**Author:** ![Yaleaura](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yaleaura](https://discourse.nodered.org/u/Yaleaura)\
**Post date:** [17 May 2021 12:58 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/8 "2021-05-17T12:58:08Z")

</div>

My broker is installed in a virtual machine on amazon. I use mosquitto. The device is well connected to the network

---

<div class="post-metadata">

**Author:** ![Yaleaura](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yaleaura](https://discourse.nodered.org/u/Yaleaura)\
**Post date:** [17 May 2021 13:02 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/9 "2021-05-17T13:02:02Z")

</div>

I deleted the spaces but it doesn't always work

---

<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:** [17 May 2021 13:03 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/10 "2021-05-17T13:03:40Z")

</div>

> [@Yaleaura](#):
>
> The device is well connected to the network

Do you mean that you know that the device has successfully connected to the broker?

Install MQTT Explorer on your pc and connect it to the broker. Then you can easily check that node-red is publishing correctly, and also can see whether the device is publishing anything.

---

<div class="post-metadata">

**Author:** ![Yaleaura](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yaleaura](https://discourse.nodered.org/u/Yaleaura)\
**Post date:** [17 May 2021 13:08 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/11 "2021-05-17T13:08:58Z")

</div>

The device is well connected to the broker because I can manually sent the data to it from the web interface of my server application.

---

<div class="post-metadata">

**Author:** ![Yaleaura](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yaleaura](https://discourse.nodered.org/u/Yaleaura)\
**Post date:** [17 May 2021 13:18 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/12 "2021-05-17T13:18:02Z")

</div>

When i add MQTT In  
 ![Cap5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/6/06f9dd60f4640a81f2b83cf2065d259c09bd5cc2.png)

 ![Cap6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f03f0d3c26d9befd704d374a6318cc9ae0165689.png)

---

<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:** [17 May 2021 13:23 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/13 "2021-05-17T13:23:19Z")

</div>

I see you still have spaces in the property name. Are you certain that is correct?

---

<div class="post-metadata">

**Author:** ![Yaleaura](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yaleaura](https://discourse.nodered.org/u/Yaleaura)\
**Post date:** [17 May 2021 13:33 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/14 "2021-05-17T13:33:08Z")

</div>

I deleted all spaces. let me check

---

<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:** [17 May 2021 15:07 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/15 "2021-05-17T15:07:45Z")

</div>

The fact that you see the data you published echoed back via the MQTT In node shows that node-red _is_ publishing the data ok.

> [@Yaleaura](#):
>
> The device is well connected to the broker because I can manually sent the data to it from the web interface of my server application.

Do you mean you can send data to it via MQTT?  
If so is that the same data that you are trying to send from node-red? If so then check that you see data published via the server application picked up by the MQTT In node.

It would be even better to use MQTT Explorer as I suggested. It is an invaluable tool when investigating MQTT problems.

---

<div class="post-metadata">

**Author:** ![Yaleaura](https://avatars.discourse-cdn.com/v4/letter/y/85e7bf/32.png) [@Yaleaura](https://discourse.nodered.org/u/Yaleaura)\
**Post date:** [17 May 2021 20:36 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/16 "2021-05-17T20:36:30Z")

</div>

I followed your suggestion but I cannot connect to the broker with MQTT Explorer. Connection is not authorized.

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [17 May 2021 20:46 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/17 "2021-05-17T20:46:27Z")

</div>

Hello @Yaleaura,

But you are aware that you have one time a string and one time an object? So the manual injection is not the same than the MQTT in?!

Cheers  
Ranki

---

<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:** [17 May 2021 20:55 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/18 "2021-05-17T20:55:39Z")

</div>

> [@Ranki](#):
>
> But you are aware that you have one time a string and one time an object? So the manual injection is not the same than the MQTT in?!

The op likely has the MQTT in node NOT set to parse JSON. What you are seeing is the object from the inject followed by the MQTT in message.

At least it proves the ops connection to MQTT broker works.

It is more likely their issue is the the other device is not connected to the MQTT broker or the message format is incorrect.

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [17 May 2021 21:02 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/19 "2021-05-17T21:02:23Z")

</div>

Oh yes, got it 😵

But if you have problems to connect with the MQTT explorer (authorization), this might be the save issue of your device. Maybe you configured an authorization to mosquito and the device does not have the credentials?

Cheers  
Ranki

---

<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:** [17 May 2021 21:19 UTC](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780/20 "2021-05-17T21:19:55Z")

</div>

> [@Yaleaura](#):
>
> I cannot connect to the broker with MQTT Explorer

How have you configured the connection in node red and how have you done it in MQTT Explorer?

[Next page](https://discourse.nodered.org/t/i-cant-publish-data-from-node-red/45780.md?page=2)
