Mqtt

Node Documentation

Connects to a MQTT broker and subscribes to messages from the specified topic.

Outputs

payload string | buffer
a string unless detected as a binary buffer.
topic string
the MQTT topic, uses / as a hierarchy separator.
qos number
0, fire and forget - 1, at least once - 2, once and once only.
retain boolean
true indicates the message was retained and may be old.
responseTopic string
MQTTv5: the MQTT response topic for the message
correlationData Buffer
MQTTv5: the correlation data for the message
contentType string
MQTTv5: the content-type of the payload
userProperties object
MQTTv5: any user properties of the message
messageExpiryInterval number
MQTTv5: the expiry time, in seconds, of the message

Details

This node requires a connection to a MQTT broker to be configured. This is configured by clicking the pencil icon.

Several MQTT nodes (in or out) can share the same broker connection if required.

Dynamic Subscription

Inputs

These only apply when the node has been configured for dynamic subscriptions.

action string
the name of the action the node should perform. Available actions are: "connect", "disconnect", "subscribe" and "unsubscribe".
topic string|object|array
For the "subscribe" and "unsubscribe" actions, this property provides the topic. It can be set as either:
  • a String containing the topic filter
  • an Object containing topic and qos properties
  • an array of either strings or objects to handle multiple topics in one
broker broker
For the "connect" action, this property can override any of the individual broker configuration settings, including:
  • broker
  • port
  • url - overrides broker/port to provide a complete connection url
  • username
  • password

If this property is set and the broker is already connected an error will be logged unless it has the force property set - in which case it will disconnect from the broker, apply the new settings and reconnect.