Skip to content

MQTT

MQTT is available by choosing the mqtt protocol on a WebSocket request.

An MQTT tab: the topic, the QoS, the Retain option, subscribe-on-connect, the client identifier, the keepalive, the last will (LWT) and the published payload

FieldRole
URLThe broker’s address (mqtt://, mqtts://, or WebSocket)
TopicThe topic, carried by the Event field
MessageThe published payload
QoS0, 1 or 2 — used both when publishing and when subscribing
RetainMarks the message as retained by the broker
Client identifierResolved by Handlebars; generated automatically if left empty
User / PasswordBroker credentials; the password accepts a Secret-typed value
KeepaliveIn seconds
Subscribe to topicEnabled by default: on connecting, Restorm subscribes to the request’s topic

The topic accepts {{variables}}capteurs/{{site}}/{{capteurId}} is a perfectly valid topic.

Four fields declare the message the broker will publish if your client disappears abruptly: the will’s topic, payload, QoS and retention.

That is exactly what you need in order to test how your system behaves in the face of an unclean disconnect: configure a will, cut the connection, and check the subscriber reacts.

The MQTT client reconnects automatically, with a ceiling of ten attempts.

MQTT connect (which subscribes to the request’s topic and emits one event per message received), MQTT publish (publishes, with the request’s QoS and retention) and MQTT close. See Connections and streams.

Restorm can host a local MQTT broker: one broker per port, reachable over raw TCP and through an MQTT-over-WebSocket gateway. See Mocking WebSocket, Socket.IO and MQTT.

An AsyncAPI document whose channels use the mqtt protocol produces MQTT requests directly (one per channel, for publishing and for subscribing), with sample payloads built from the messages’ schema. See Importing AsyncAPI.