MQTT Thingsboard; no trace

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
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
As soon i inject, it shows red : not connected.
very strange :wink:
any help ?
best regards
C

Have you looked at the Node-RED log?

1 Like

How can i have a log between Node and MQTT ?

thx !

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

1 Like

ah : tank you very much !

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

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

1 Like

just connects an disconnects

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

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.

1 Like

ah : changes a lot :slight_smile:
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

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

#!/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"

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).

1 Like

I left the MQTT Client ID's empty


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 !

The script you posted has the broker name as

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

that's correct ; mine is cloud.thingsboard.io

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

2 Likes

Hi :slight_smile:
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

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?

1 Like

image

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.