# MQTT into function cannot read message

**URL:** <https://discourse.nodered.org/t/mqtt-into-function-cannot-read-message/49148>\
**Category:** General\
**Created:** [31 July 2021 18:57 UTC](https://discourse.nodered.org/t/mqtt-into-function-cannot-read-message/49148 "2021-07-31T18:57:18Z")\
**Posts on this page:** 6\
**Page:** 2

<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:** [1 August 2021 23:25 UTC](https://discourse.nodered.org/t/mqtt-into-function-cannot-read-message/49148/21 "2021-08-01T23:25:48Z")

</div>

There is no `topic` in that debug output.

If you add an inject with the topic set, connected to a `mqtt-out` pointing at the broker, you can test it by sending the msg out and it comes back in the `mqtt-in`

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [1 August 2021 23:26 UTC](https://discourse.nodered.org/t/mqtt-into-function-cannot-read-message/49148/22 "2021-08-01T23:26:40Z")

</div>

That is correct

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [1 August 2021 23:27 UTC](https://discourse.nodered.org/t/mqtt-into-function-cannot-read-message/49148/23 "2021-08-01T23:27:43Z")

</div>

The mqtt outputs only on or off, where would the topic get injected from? My ESP which is where the data comes from sets no topic

---

<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:** [1 August 2021 23:33 UTC](https://discourse.nodered.org/t/mqtt-into-function-cannot-read-message/49148/24 "2021-08-01T23:33:08Z")

</div>

mqtt works by having a 'broker' that routes msgs to 'subscribers' based on the 'topic' that the subscriber - subscribes to. The msg coming out of an mqtt-out node should contain the topic along with the payload.

When I send a msg to a `mqtt-out` node and add a debug to the output of the `mqtt-in` node, this is what I get:

![Screen Shot 2021-08-01 at 7.30.54 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a8006653d74cecbd7e9462f40a008916774cb17e.png)

Notice the topic is there along with the `qos` and `retain`.

What is creating the msg being published?

[edit] p.s. add a `debug` node(set to display the complete msg object) to the output odf the `function` node.

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [2 August 2021 02:25 UTC](https://discourse.nodered.org/t/mqtt-into-function-cannot-read-message/49148/25 "2021-08-02T02:25:32Z")

</div>

Didn't realize all the info that should have been in the message from mqtt. Stopped and restarted mosquitto and things seem back to normal  
Thanks all

---

<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:** [16 August 2021 02:25 UTC](https://discourse.nodered.org/t/mqtt-into-function-cannot-read-message/49148/26 "2021-08-16T02:25:34Z")

</div>

Closed on 16 August 2021 02:25 UTC

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

[Previous page](https://discourse.nodered.org/t/mqtt-into-function-cannot-read-message/49148.md?page=1)
