I can't publish data from node-red

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

What does the debug node show?


So the inject node works. Might be the pushData node is not correctly configured... maybe wrong mqtt topic?

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.

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

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

I deleted the spaces but it doesn't always work

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.

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.

When i add MQTT In

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

I deleted all spaces. let me check

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.

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.

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

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?!


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.

Oh yes, got it :dizzy_face:

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?


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