# MQTT Thingsboard; no trace

**URL:** <https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047>\
**Category:** General\
**Created:** [23 October 2019 10:35 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047 "2019-10-23T10:35:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [23 October 2019 10:35 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/1 "2019-10-23T10:35:19Z")

</div>

Hi there  
i've got a NR instance on RPI up and running.  
Some Modbus sensors sending MQTT Messages to test successfully to hive broker; works fine  
I can re-read them even from the broker:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a38ace47a55999592ba8df1c7c3f966a1fd85a87.png)  
I want to send the messages to Thingsboard, Configured the same way like the hive one.  
correct topic, Access token as user name.  
And NR finds it it connected  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a7fc25de298fb9ad2b5da1782cd92036bdaa1f49.png)  
As soon i inject, it shows red : not connected.  
very strange 😉  
any help ?  
best regards  
C

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [23 October 2019 10:41 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/2 "2019-10-23T10:41:28Z")

</div>

Have you looked at the Node-RED log?

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [23 October 2019 13:00 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/3 "2019-10-23T13:00:32Z")

</div>

How can i have a log between Node and MQTT ?

thx !

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [23 October 2019 13:02 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/4 "2019-10-23T13:02:22Z")

</div>

You can't, but you can have a log in Node-RED which may say why it was disconnected

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [23 October 2019 14:03 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/5 "2019-10-23T14:03:55Z")

</div>

ah : tank you very much !

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

comes back with a cryptic debug message:  
[debug:85734ebe.c0e28] {"data":[2099],"buffer":{"type":"Buffer","data":[8,51]}}

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [23 October 2019 14:23 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/6 "2019-10-23T14:23:03Z")

</div>

Can you try sending a simple short test string e.g "hello" instead of your normal payload and see what happens then?

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [23 October 2019 14:26 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/7 "2019-10-23T14:26:30Z")

</div>

just connects an disconnects

23 Oct 15:25:11 - [info] [mqtt-broker:NHINV] Connected to broker: [https://cloud.thingsboard.io](https://cloud.thingsboard.io)  
23 Oct 15:25:16 - [info] [mqtt-broker:NHINV] Disconnected from broker: [https://cloud.thingsboard.io](https://cloud.thingsboard.io)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [23 October 2019 14:40 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/8 "2019-10-23T14:40:35Z")

</div>

> [@claib](#):
>
> comes back with a cryptic debug message:  
> [debug:85734ebe.c0e28] {"data":[2099],"buffer":{"type":"Buffer","data":[8,51]}}

It's not that cryptic. Its the code for the debug node the message is coming from followed by the msg.payload.  
But it also shows you are trying to connect to `https://cloud.thingsboard.io` any reason for that rather than using normal MQTT? I'd check the details of the MQTT broker you are trying to send the messages to.

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [23 October 2019 14:49 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/9 "2019-10-23T14:49:29Z")

</div>

ah : changes a lot 🙂  
23 Oct 15:47:03 - [info] [mqtt-broker:NHINV] Connected to broker: mqtt://cloud.thingsboard.io:1883  
23 Oct 15:47:10 - [info] [mqtt-broker:NHINV] Disconnected from broker: mqtt://cloud.thingsboard.io:1883  
23 Oct 15:47:26 - [info] [mqtt-broker:NHINV] Connected to broker: mqtt://cloud.thingsboard.io:1883  
23 Oct 15:47:33 - [info] [debug:85734ebe.c0e28] {"data":[1680],"buffer":{"type":"Buffer","data":[6,144]}}

But still the debug message

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [23 October 2019 14:52 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/10 "2019-10-23T14:52:49Z")

</div>

Here is a script from Thingsboard for Mosquito that should work.  
Do i have to send attributes first ?

```auto
#!/bin/sh

# Set ThingsBoard host to "demo.thingsboard.io" or "localhost"
THINGSBOARD_HOST="demo.thingsboard.io"
# Replace YOUR_ACCESS_TOKEN with one from Device details panel.
ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
# Publish serial number and firmware version attributes
mosquitto_pub -d -h "$THINGSBOARD_HOST" -t "v1/devices/me/attributes" -u "$ACCESS_TOKEN" -f "attributes-data.json"
# Publish timeseries data as an object without timestamp (server-side timestamp will be used)
mosquitto_pub -d -h "$THINGSBOARD_HOST" -t "v1/devices/me/telemetry" -u "$ACCESS_TOKEN" -f "telemetry-data.json"

```

---

<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:** [23 October 2019 14:55 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/11 "2019-10-23T14:55:44Z")

</div>

A common reason for repeated disconnections is that you have used an mqtt client id that is used in another connection. Each time one client sends something the other one gets disconnected, though this doesn't quite match what you are seeing I thought I should mention it. The two connections could be two mqtt out nodes in the same node red if they have two mqtt config nodes (rather than re-using one config node in mutliple mqtt nodes).

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [23 October 2019 15:04 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/12 "2019-10-23T15:04:19Z")

</div>

I left the MQTT Client ID's empty

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0b00dae04a4e8615ca93d3292baabc73c6b09c40.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d8db7ab2e63dd30d90c8dbceb4fc6d23edd0a5cf.png)

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [23 October 2019 15:07 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/13 "2019-10-23T15:07:02Z")

</div>

the green arrows point to the hive broker with it's return  
the red arrow point to the Thinksboard

Oh : j saw that the debug message comes from the green node, not from ThingsBoard !

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [23 October 2019 16:41 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/14 "2019-10-23T16:41:10Z")

</div>

The script you posted has the broker name as

> [@claib](#):
>
> [demo.thingsboard.io](http://demo.thingsboard.io)"

Your config has the broker name as  
`cloud.thingsboard.io`

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [23 October 2019 16:43 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/15 "2019-10-23T16:43:48Z")

</div>

that's correct ; mine is [cloud.thingsboard.io](http://cloud.thingsboard.io)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [23 October 2019 17:44 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/16 "2019-10-23T17:44:33Z")

</div>

I've created a thingsboard account but don't understand how to use it.

I did get an access token and when I used that as my username - it connected

But like you, as soon as I sent some data it disconnected

So I think the problem is at thingsboard

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [24 October 2019 06:40 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/17 "2019-10-24T06:40:53Z")

</div>

Hi 🙂  
if i use the Mosquitto broker on the Raspi with the adapted script, it works....  
strange.  
It seems that NR and TB are not to compatible regarding mqtt

---

<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:** [24 October 2019 07:01 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/18 "2019-10-24T07:01:36Z")

</div>

The fact Thingsboard disconnects you when you publish a message means it is probably going to be a problem with either the topic or payload format you are using.

I don't see an example of the payload you are using anywhere in the thread. Could add a debug node next to the mqtt nodes and show us what the payload looks like?

---

<div class="post-metadata">

**Author:** ![claib](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/claib/32/12809_2.png) [@claib](https://discourse.nodered.org/u/claib)\
**Post date:** [25 October 2019 07:53 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/19 "2019-10-25T07:53:46Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/788b09bcc9bb953e4d7c266f240365e1bacfdcff.png)

---

<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:** [25 October 2019 08:06 UTC](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047/20 "2019-10-25T08:06:14Z")

</div>

And how does that compare to what you publish successfully using `mosquitto_pub`?

The commands you shared previously showed you were sending data from the file `telemetry-data.json` but we can't see what that file contains.

[Next page](https://discourse.nodered.org/t/mqtt-thingsboard-no-trace/17047.md?page=2)
