Docs / Strand / connectors/mqtt

MQTT Publish

Direction: Write Only | Type: mqtt

Publish messages to MQTT message brokers with support for TLS/SSL, authentication, and Quality of Service levels.

Operations

Operation Direction Description
publish Write Publish a message to an MQTT topic

Connector Configuration

Field Required Default Description
Broker URL Yes - MQTT broker address (mqtt:// or mqtts://)
Client ID No Auto MQTT client identifier
Username No - Broker username (encrypted)
Password No - Broker password (encrypted)
Keepalive No 60 Keepalive interval in seconds
Clean Session No true Start with a clean session
TLS No - TLS/SSL configuration (see below)
Topic No - Default topic (can be overridden at node level)
QoS No 0 Default Quality of Service (0, 1, or 2)
Timeout No 30 Connection timeout in seconds
Retain No false Retain messages on broker

TLS/SSL Configuration

json

{
  "tls": {
    "enabled": true,
    "ca_certs": "/path/to/ca-cert.pem",
    "certfile": "/path/to/client-cert.pem",
    "keyfile": "/path/to/client-key.pem",
    "cert_reqs": "required",
    "tls_version": "tlsv1.2"
  }
}
Field Default Options
enabled false Enable TLS/SSL
ca_certs - CA certificate file for server validation
certfile - Client certificate for mutual TLS
keyfile - Client private key for mutual TLS
cert_reqs required none, optional, required
tls_version tlsv1.2 tlsv1, tlsv1.1, tlsv1.2, tlsv1.3

Quality of Service (QoS)

Level Delivery Description
0 At most once Fire and forget (fastest)
1 At least once Acknowledged delivery
2 Exactly once Guaranteed delivery (slowest)

Node Configuration

Field Required Description
Topic Yes MQTT topic to publish to (supports Jinja2)
QoS No Override connector default QoS
Retain No Override connector default retain
Payload No Message payload (string/object, defaults to event payload as JSON)
Timeout No Override connector default timeout

Output

json

{
  "success": true,
  "status": "sent",
  "data": {
    "topic": "sensors/temperature",
    "message_id": 1,
    "qos": 1
  },
  "service": "mqtt",
  "operation": "publish"
}

Example

Connector Setup:

json

{
  "broker_url": "mqtts://broker.example.com:8883",
  "username": "mqtt_user",
  "password": "mqtt_password",
  "tls": { "enabled": true, "cert_reqs": "required" },
  "qos": 1
}

Node Configuration: