Bird
0
0

What output do you expect when running mosquitto_pub -h localhost -t sensors/temperature -m "22.5" and simultaneously running mosquitto_sub -h localhost -t sensors/temperature in another terminal?

medium📝 Predict Output Q4 of 15
Raspberry Pi - MQTT for IoT
What output do you expect when running mosquitto_pub -h localhost -t sensors/temperature -m "22.5" and simultaneously running mosquitto_sub -h localhost -t sensors/temperature in another terminal?
AAn error message appears indicating connection failure
BThe publisher terminal displays the message: 22.5
CBoth terminals remain silent with no output
DThe subscriber terminal displays the message: 22.5
Step-by-Step Solution
Solution:
  1. Step 1: Understand the commands

    mosquitto_pub publishes a message to a topic, and mosquitto_sub subscribes to that topic to receive messages.
  2. Step 2: Analyze the topic and message

    The publisher sends "22.5" to the topic sensors/temperature, which the subscriber listens to.
  3. Final Answer:

    The subscriber terminal will display the message: 22.5 -> Option D
  4. Quick Check:

    Subscriber receives published message [OK]
Quick Trick: Subscriber shows messages published to its topic [OK]
Common Mistakes:
MISTAKES
  • Expecting publisher to display the message
  • Thinking no output appears without explicit print
  • Assuming error without broker running

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes