Skip to content

Command line (mosquitto) ​

The quickest way to check your credentials: two terminal windows, one subscriber and one publisher.

Install the clients ​

OSCommand
Ubuntu / Debiansudo apt install mosquitto-clients
macOS (Homebrew)brew install mosquitto
WindowsInstall Mosquitto from mosquitto.org/download; the tools are in C:\Program Files\mosquitto.

Subscribe ​

Replace the placeholders with the values from Credentials & endpoints.

bash
mosquitto_sub -h broker.connectmq.com -p 8883 --capath /etc/ssl/certs \
  -i YOUR_CLIENT_ID_sub \
  -u YOUR_USERNAME -P 'YOUR_PASSWORD' \
  -t 'acme/istanbul/assembly/#' -v

Publish ​

In a second terminal:

bash
mosquitto_pub -h broker.connectmq.com -p 8883 --capath /etc/ssl/certs \
  -i YOUR_CLIENT_ID_pub \
  -u YOUR_USERNAME -P 'YOUR_PASSWORD' \
  -t 'acme/istanbul/assembly/line1/cnc-01/telemetry' \
  -m '{"temperature":62.4,"spindleRpm":11950}' -q 1

The subscriber prints the message, and the topic appears in the console's topic tree a moment later.

TLS options

  • Linux: --capath /etc/ssl/certs uses the system CA store.
  • macOS / Windows: use --tls-use-os-certs (Mosquitto 2.0+) instead of --capath.
  • The broker certificate is publicly trusted, so you never need --insecure.

Useful flags ​

FlagMeaning
-iClient ID. Must be your issued client ID or start with <client ID>_, see Client IDs. Use different suffixes for the subscriber and the publisher.
-q 0/1/2QoS level.
-rPublish as a retained message.
-V mqttv5Use MQTT 5 (default is 3.1.1).
-dDebug output, shows CONNACK reason codes.
--will-topic, --will-payloadLast Will and Testament.

If the connection is refused, run with -d and look up the reason code in Troubleshooting.

Fully managed MQTT broker for connected devices.