Verification tools
Most MQTT problems come down to one question: who sent what to which topic, and whom did the broker forward it to? This page lists the tools that answer it.
Watch traffic with mosquitto_sub
Section titled “Watch traffic with mosquitto_sub”Run mosquitto_sub with a wildcard filter to see the messages that pass through the broker.
Always pass -V 5 to see MQTT 5.0 properties.
mosquitto_sub -V 5 -t 'opcua/#' -F '%t qos=%q retain=%r content-type=%C user-properties=%P %l bytes'-F code |
Prints |
|---|---|
%t |
The topic |
%q, %r |
The QoS and RETAIN flag as received |
%C |
The Content Type property |
%P |
User properties (name:value, comma-separated) |
%l |
The payload length in bytes |
%x |
The payload in hex |
%p |
The raw payload |
%I |
The time of receipt (ISO 8601) |
%j |
The whole message as one JSON line |
-F '%j' includes the properties in JSON:
{"tst":"2026-10-15T02:07:35.001558+0900","topic":"demo/a","qos":0,"retain":false,"payloadlen":2,"properties":{"content-type":"text/plain","user-properties":[{"k":"v"}]},"payload":"hi"}Other useful options:
| Option | Meaning |
|---|---|
-q 1 |
Subscribe at QoS 1 instead of the default QoS 0. |
-C <count> |
Exit after that many messages. |
-W <seconds> |
Print Timed out and exit with code 27 if the client is still running after that time. |
-N |
Don’t add a newline after the payload; use it to save binary payloads to a file. |
-d |
Print the packets the client sends and receives. |
Inject messages with mosquitto_pub
Section titled “Inject messages with mosquitto_pub”To test whether a simulator subscriber accepts a message, publish it with the OPC UA PubSub properties:
mosquitto_pub -V 5 -q 1 -t opcua/uadp/data/77/demo \ -D publish content-type application/opcua+uadp \ -D publish user-property UAMessageType ua-data \ -f dataset.bin-f sends the file content as the payload. Publish and subscribe with the simulator shows how to capture a UADP payload.
Read the broker log
Section titled “Read the broker log”Mosquitto started with mosquitto -v or log_type all writes one line per packet:
New client connected from 127.0.0.1:64658 as pdcomm-opcua-sim-79619-17 (p5, c1, k30).Received SUBSCRIBE from pdcomm-opcua-sim-79619-17 opcua/uadp/data/77/quickstart (QoS 1)Received PUBLISH from pdcomm-opcua-sim-79619-17 (d0, q1, r0, m2, 'opcua/uadp/data/77/quickstart', ... (48 bytes))Sending PUBLISH to pdcomm-opcua-sim-79619-17 (d0, q1, r0, m1, 'opcua/uadp/data/77/quickstart', ... (48 bytes))Sending PUBACK to pdcomm-opcua-sim-79619-17 (m2, rc0)| Notation | Meaning |
|---|---|
p5, c1, k30 |
MQTT 5.0, Clean Start 1, keep alive 30 seconds. A certificate or user name adds u'…'. |
d0, q1, r0, m2 |
DUP 0, QoS 1, RETAIN 0, packet identifier 2 |
rc0 |
Reason code 0x00 (Success); rc135 is 0x87 (Not authorized) |
Denied PUBLISH from … |
An ACL refused the publication. |
disconnected: not authorised. |
Authentication failed and the broker closed the connection. |
The simulator’s client identifier is pdcomm-opcua-sim-<process ID>-<DataSetWriterId>, which tells you which simulator a log line belongs to.
$SYS topics
Section titled “$SYS topics”Mosquitto publishes broker information under $SYS/broker/ and refreshes it every sys_interval seconds (10 by default):
mosquitto_sub -V 5 -t '$SYS/broker/version' -t '$SYS/broker/clients/connected' -t '$SYS/broker/messages/received' -v$SYS/broker/version mosquitto version 2.1.2Filters that start with # don’t match $SYS, so subscribe to $SYS topics explicitly.
Read the simulator status
Section titled “Read the simulator status”The PubSub status of the simulator (the GUI status line or headless pubsub_status) tells you a lot on its own:
| You see | It means | Check next |
|---|---|---|
sent stays above acknowledged |
The broker didn’t send a PUBACK, or answered with a failure. | MQTT publish refused: 0x.. in error, Denied PUBLISH in the broker log |
rejected grows |
Messages arrived but their format or properties didn’t match. | The error value and Delivery problems |
The observer sees messages but received doesn’t change |
The topic differs, or the broker withholds messages the simulator may not read. | The simulator topic and the ACL |
running is false and error starts with MQTT: |
The broker connection dropped. | The broker log and Connection problems |
dropped grows |
Nobody took the received messages, and the queue of 256 overflowed. | Run pubsub_received or click Show received more often. |
The simulator trace
Section titled “The simulator trace”The simulator records every action in its trace. In the GUI, click Refresh trace on the Trace & Diagnostics tab; in headless mode, send {"action":"trace"}.
Failed actions keep their error message:
{"action":"pubsub_start","elapsed_us":112,"error":"MQTT broker connection failed: MQTT transport I/O: ConnectionRefused","ok":false,"sequence":2,"time_ms":0,"workspace":"pubsub"}Turn on the diagnostic log file with Diagnostic log (off by default) and Apply logging on the same tab, or with logging_configure in headless mode:
{"action":"logging_configure","config":{"enabled":true,"file":"logs/opcua-simulator.jsonl"}}The log format and levels are described with the diagnostic logging docs in the Tools section.