Skip to content
Download

MQTT requests

Connect to an MQTT broker, subscribe to topics and publish messages over MQTT 3.1, 3.1.1 or 5.

An MQTT request connects to a broker and stays connected, so you can subscribe to device topics, publish commands and watch both in one log.

  1. Choose MQTT in the protocol picker and enter the broker URL.
  2. Pick MQTT 5, MQTT 3.1.1 or MQTT 3.1 next to the URL.
  3. Add credentials in Auth if the broker needs them.
  4. Click Connect. The connection stays open until you click Disconnect.
URLTransportDefault port
mqtt://host or hostTCP1883
mqtts://hostTLS8883
ws://host/pathWebSocket80
wss://host/pathWebSocket over TLS443

Broker URLs, topics, payloads, client IDs and properties accept workspace variables.

MQTT request connected to a broker, with a published command and a received reply

Open Topics, enter a topic and click Add. Use + for one level and # for every level below, as in devices/+/telemetry or devices/#. Pick the QoS for each subscription, and add a description to document what the topic carries.

Topics that are turned on are subscribed when you connect. While connected, turning a topic on subscribes to it at once and turning it off unsubscribes. A green dot marks topics the broker has confirmed.

MQTT topics with one active subscription

  1. Open Message and enter the topic.
  2. Choose a QoS, and turn on Retain if the broker should keep the message for new subscribers.
  3. Pick the message type: Text, JSON, Base64 or Hexadecimal. Base64 and hexadecimal payloads are decoded and sent as raw bytes.
  4. Press Send, or Cmd/Ctrl Enter, while connected.

With MQTT 5, Properties in the message toolbar adds a content type, response topic, correlation data, message expiry, topic alias, the UTF-8 payload flag and user properties.

Saved keeps messages you publish often: a name, the topic, the payload, its type, QoS and the retain flag. Click a saved message to load it, or send it straight away while connected.

The panel below the editor lists connection events and sent and received messages, newest first, with a colour for each topic. Its header is the same as in the WebSocket message log: filter by Received, Sent or Connection events, type a topic filter, or search topics and payloads. The topic filter matches part of a topic name, or a whole MQTT filter such as plant/+/telemetry or plant/line-1/#.

Click a message to see its topic, QoS, retain flag, size, MQTT 5 properties and the formatted payload. Connection lists the broker, client ID, MQTT version and subscriptions.

  • Auth: choose Username and password to send credentials with CONNECT.
  • Properties (MQTT 5): session expiry, receive maximum, maximum packet size, topic alias maximum, requests for response and problem information, and user properties.
  • Last Will: a message the broker publishes when the connection drops without a clean disconnect. Set its topic, QoS, retain flag and payload. MQTT 5 adds a delay and the same properties as a published message.

To start from a spec, import an AsyncAPI document: Kurlo fills in the broker, subscriptions and saved messages.

  • Client ID: empty uses a new random ID for each connection.
  • Clean session (Clean start in MQTT 5): starts without the subscriptions and queued messages of an earlier session. Turn it off and set a fixed client ID to resume a session.
  • Keep alive: how long, in seconds, the connection may stay silent before the broker drops it, 60 by default. Kurlo pings before it runs out. 0 turns pings off.
  • Connection timeout: 30 seconds by default.
  • Auto reconnect: reconnects after the connection drops, up to 10 attempts, and subscribes to the same topics again. When the attempts run out or the broker refuses the connection, the request shows the error and Connect starts again.
  • Verify server certificate and Client certificate apply to mqtts:// and wss:// brokers.
  • Proxy: ws:// and wss:// brokers use the request, collection or global proxy, including the system proxy. mqtt:// and mqtts:// brokers go through an HTTP, HTTPS or SOCKS5 proxy only when one is set in Kurlo, with On or a proxy URL; system proxy variables are not used for them, because most HTTP proxies allow tunnels only to web ports. Bypass rules apply to both.

MQTT connection settings with a fixed client ID and a client certificate

  • WebSocket path. A WebSocket URL without a path connects to /mqtt.
  • Locked picker. While connected, the protocol picker is locked.
  • Wildcards. Kurlo rejects a filter with a misplaced wildcard before it reaches the broker.
  • QoS 1 and 2. A message waits up to 15 seconds for the broker to acknowledge it. If the connection drops first, Kurlo reports the error at once.
  • Log size. The log keeps the last 5,000 messages and shows the first 256 KB of a larger message; its full size is listed in the details. A payload that is not valid UTF-8 is shown as Base64.
  • Fast brokers. The log and the topic list draw only the rows on screen, so thousands of messages or subscriptions stay responsive. When a broker sends faster than the log can draw, Kurlo keeps the newest messages and notes how many it left out. Received messages are still acknowledged to the broker.
  • Export. MQTT requests are saved in the workspace YAML and exported to Postman and Insomnia files that Kurlo can import again.
  • Scripts and runs. MQTT requests do not run scripts, and the Collection Runner and kurlo run skip them because a connection does not finish on its own.
  • Not supported. MQTT 5 enhanced authentication (AUTH packets).