How to test an MQTT broker in API Spector
MQTT is the publish and subscribe protocol behind a lot of IoT and messaging systems. API Spector now speaks it, so you can connect to a broker, subscribe to topics, and publish messages next to your HTTP and WebSocket requests.
Switch a request to MQTT
In the request's protocol switcher, alongside HTTP, WS, SOAP, gRPC, and IO, choose MQTT. The URL bar becomes the broker address. API Spector connects over TCP with mqtt:// and mqtts://, and over WebSocket with ws:// and wss://, for example mqtt://broker.example.com:1883.
Connect
Fill in the connection details below the URL: an optional Client ID, which is generated for you if you leave it empty, a Username and Password, and the Clean session flag. The password field understands {{variables}}, so you can reference a secret from your environment instead of typing it into the request. Pick a default QoS of 0, 1, or 2, then click Connect. The status dot turns green when the broker accepts the connection.
Subscribe to topics
Enter a topic or a wildcard filter in the Subscribe field, such as sensors/# or devices/+/status, and click Subscribe. Every message the broker delivers appears in the session log with its topic, its QoS, and a retain marker when the broker set one. Unsubscribe stops that topic without dropping the connection.
Publish messages
Set a Publish topic, type a payload, and click Publish, or press Ctrl+Enter. The retain checkbox and the QoS apply to what you send. Your published message shows in the same log, so when you are subscribed to the same topic you see the full round trip.
Why it helps
Testing a broker used to mean a separate tool or a command line client. With MQTT in API Spector the broker sits in the same workspace as your REST and realtime requests, with the same variables and the same session file, and a publish and its echo show up side by side in one log.