Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors
22.5k Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

MQTT

Use this node to publish incoming message data to an external MQTT broker — for example, forwarding device telemetry to a cloud IoT platform, delivering commands to field devices through a dedicated broker, or bridging ThingsBoard data to a third-party MQTT-based service.

  • Topic pattern — required. MQTT topic where messages will be published. Supports templatization.
  • Host — required. MQTT broker hostname or IP.
  • Port — required. MQTT broker port.
  • Connection timeout (sec) — required. Maximum time to wait when establishing the connection.

Optional. Leave empty for auto-generated netty-mqtt/XXXXXXXX. In clustered deployments:

  • Singleton mode (default) — one rule node instance per cluster, one connection.
  • Disabled singleton + Add Service ID as suffix — one connection per rule engine instance, each with a unique client ID.
  • Parse to plain text — when enabled, removes outer JSON string encoding from message data before publishing (useful for string payloads). Regular JSON objects are unaffected.
  • QoS — fixed at QoS 1 (at-least-once).
  • Retained — when enabled, the broker stores and delivers the message to future subscribers.

MQTT 3.1, MQTT 3.1.1 (default), or MQTT 5.

  • Clean session — enabled by default; broker does not store session state between connections.
  • Enable SSL — use TLS encryption.
  • Credentials — Anonymous, Basic (username/password), or PEM Certificate (CA cert, client cert, private key).

For unacknowledged QoS 1 messages, the client uses exponential backoff with jitter. Configure globally via environment variables:

Variable Default
TB_MQTT_CLIENT_RETRANSMISSION_MAX_ATTEMPTS 3
TB_MQTT_CLIENT_RETRANSMISSION_INITIAL_DELAY_MILLIS 5000
TB_MQTT_CLIENT_RETRANSMISSION_JITTER_FACTOR 0.15

Controlled by the ACTORS_RULE_EXTERNAL_NODE_FORCE_ACK environment variable. When true, the incoming message is acknowledged immediately and the publish operation runs asynchronously.

  1. Establish a persistent connection to the broker on node startup.
  2. For each incoming message: resolve the topic pattern; optionally strip JSON string encoding; publish with QoS 1.
  3. On success: route via Success. On failure: add error to metadata and route via Failure.
  4. On node shutdown (config update or deletion): disconnect gracefully and release resources.
Connection Condition
Success Message published and acknowledged by broker.
Failure Publish failed, retransmission exhausted, or unexpected error. Error details in metadata error key.

Example 1 — Forward telemetry to cloud broker

Section titled “Example 1 — Forward telemetry to cloud broker”

Metadata: { "deviceType": "temperature", "deviceName": "sensor-warehouse-01" } | Data: { "temperature": 22.5, "humidity": 65 }.

{
"topicPattern": "factory/sensors/${deviceType}/${deviceName}",
"host": "mqtt.cloud-provider.com",
"port": 8883,
"connectTimeoutSec": 10,
"clientId": "thingsboard-publisher",
"appendClientIdSuffix": true,
"retainedMessage": false,
"cleanSession": true,
"ssl": true,
"parseToPlainText": false,
"protocolVersion": "MQTT_3_1_1",
"credentials": { "type": "basic", "username": "factory-user", "password": "secure-password" }
}

Result: message published to factory/sensors/temperature/sensor-warehouse-01 over TLS. Routes via Success.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TbMqttNodeConfiguration",
"type": "object",
"required": ["topicPattern", "host", "port", "connectTimeoutSec", "cleanSession", "ssl", "retainedMessage", "parseToPlainText", "protocolVersion", "credentials"],
"additionalProperties": false,
"properties": {
"topicPattern": { "type": "string" },
"host": { "type": "string" },
"port": { "type": "integer" },
"connectTimeoutSec": { "type": "integer" },
"clientId": { "type": "string" },
"appendClientIdSuffix": { "type": "boolean" },
"retainedMessage": { "type": "boolean" },
"cleanSession": { "type": "boolean" },
"ssl": { "type": "boolean" },
"parseToPlainText": { "type": "boolean" },
"protocolVersion": { "type": "string", "enum": ["MQTT_3_1", "MQTT_3_1_1", "MQTT_5"] },
"credentials": { "type": "object" }
}
}