You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows10环境下未注册设备MQTT上报至ThingsBoard网关报错求助

Alright, let's break down what's going wrong here and get your ThingsBoard setup working smoothly.

First, fix the ThingsBoard server's "Invalid message received" error

The root cause here is the MQTT topic you're using. The default JsonMqttAdaptor in ThingsBoard expects telemetry data to be sent to a specific topic format—v1/devices/me/telemetry. When you publish to your custom sensors topic, the server can't parse the message structure it expects, hence the "invalid message" log entries.

Update your Mosquitto publish command to use the correct topic:

mosquitto_pub -h localhost -p 1883 -u "XXXXXXXX" -t "v1/devices/me/telemetry" -m '{"serialNumber":"TB-GW-SN-001","model":"TB-GW-T1000","temperature":35.2}'

(Note: The XXXXXXXX username should be the access token of an active device you've created in ThingsBoard—double-check this token matches what's in your device profile.)

Next, resolve the gateway's connection failure

Your gateway is trying to connect to the server's MQTT port with anonymous credentials, but your server clearly requires authentication (you're using -u "XXXXXXXX" in your Mosquitto command). The server rejects the anonymous connection attempt, leading to the Connection lost and EOFException errors in the gateway logs.

Modify your mqtt-config.json to use the same authentication as your publish command:

"brokers": [
  {
    "host": "localhost",
    "port": 1883,
    "ssl": false,
    "retryInterval": 3000,
    "credentials": {
      "type": "basic",
      "username": "XXXXXXXX",
      "password": "" // Leave empty if you're only using the access token as the username
    }
  }
]

Restart the ThingsBoard gateway after making this change, and the connection errors should disappear.

A quick sanity check on your setup

Wait—do you actually need the gateway for your use case? If you're directly sending device data to the ThingsBoard server via MQTT (like your Mosquitto command does), the gateway isn't necessary. The gateway is designed to bridge external MQTT brokers (or other protocols) to ThingsBoard. If you do need the gateway, consider adjusting your setup:

  1. Run a separate MQTT broker (e.g., another Mosquitto instance) on a different port (like 1884)
  2. Configure the gateway to connect to this 1884 broker
  3. Publish your Mosquitto messages to port 1884, and let the gateway forward them to ThingsBoard

This avoids conflicts between direct device connections and gateway connections to the server's MQTT port.

Final verification steps

  • Run netstat -ano | findstr :1883 in Command Prompt to confirm only the ThingsBoard server is using port 1883
  • Ensure the device linked to your XXXXXXXX access token is active in the ThingsBoard UI
  • Restart both the server and gateway after any configuration changes

内容的提问来源于stack exchange,提问作者MaMuDragon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:51:35