Challenge - 5 Problems
MQTT Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of mosquitto_pub with QoS 1
What is the output or result when running this command?
mosquitto_pub -h test.mosquitto.org -t "home/temperature" -m "22" -q 1
IOT Protocols
mosquitto_pub -h test.mosquitto.org -t "home/temperature" -m "22" -q 1
Attempts:
2 left
💡 Hint
The -q flag sets the Quality of Service level for message delivery.
✗ Incorrect
The command publishes the message "22" to the topic "home/temperature" on the public broker with QoS 1, which means the message is delivered at least once. The command exits successfully.
💻 Command Output
intermediate2:00remaining
mosquitto_sub output for retained messages
If a retained message "ON" exists on topic "home/lights", what will this command output immediately after subscribing?
mosquitto_sub -h test.mosquitto.org -t "home/lights"
IOT Protocols
mosquitto_sub -h test.mosquitto.org -t "home/lights"Attempts:
2 left
💡 Hint
Retained messages are sent to new subscribers immediately.
✗ Incorrect
When subscribing to a topic with a retained message, mosquitto_sub receives and prints that retained message right away before waiting for new messages.
❓ Configuration
advanced2:30remaining
Correct mosquitto_pub command to use TLS with client certificate
Which mosquitto_pub command correctly publishes message "Hello" to topic "secure/topic" using TLS with client certificate and key files located at /certs/client.crt and /certs/client.key?
Attempts:
2 left
💡 Hint
TLS requires specifying the CA file and client cert/key along with the secure port.
✗ Incorrect
Option A correctly specifies the CA certificate file, client certificate, client key, and uses the standard TLS port 8883. This enables secure TLS connection with client authentication.
❓ Troubleshoot
advanced2:00remaining
Troubleshooting mosquitto_sub connection failure
You run this command:
But it fails to connect. What is the most likely cause?
mosquitto_sub -h 192.168.1.100 -t "sensor/data" -p 1884
But it fails to connect. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check the broker's listening port and firewall settings.
✗ Incorrect
By default, mosquitto brokers listen on port 1883. If the broker is not configured to listen on 1884, the connection will fail. The topic name is valid, and -m is not required for subscribing.
🔀 Workflow
expert3:00remaining
Sequence to test message delivery with mosquitto_pub and mosquitto_sub
Arrange the steps in correct order to test publishing and subscribing to a topic using mosquitto_pub and mosquitto_sub on the same machine.
Attempts:
2 left
💡 Hint
Subscribe first to receive messages published after subscription.
✗ Incorrect
You must start the subscriber first to listen for messages. Then publish the message. The subscriber will output the message, and finally you can stop the subscription.