0
0
IOT Protocolsdevops~20 mins

Last Will and Testament (LWT) in IOT Protocols - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
LWT Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the primary purpose of Last Will and Testament (LWT) in MQTT?

In MQTT, the Last Will and Testament (LWT) feature is used to:

ASchedule messages to be sent at a later time
BAuthenticate clients before connection
CEncrypt messages between clients
DNotify other clients if a client disconnects unexpectedly
Attempts:
2 left
💡 Hint

Think about what happens if a device suddenly loses connection without warning.

💻 Command Output
intermediate
2:00remaining
What output does this MQTT client command produce regarding LWT?

Consider this MQTT client connection command with LWT settings:

mosquitto_pub -h broker.example.com -t 'status/device1' -m 'offline' --will-topic 'status/device1' --will-message 'offline' --will-qos 1 --will-retain

What happens if the client disconnects unexpectedly?

ABroker publishes 'offline' to 'status/device1' with QoS 0 and no retain
BBroker publishes 'offline' to 'status/device1' with QoS 1 and retain flag set
CClient sends 'offline' message before disconnecting gracefully
DNo message is published on unexpected disconnect
Attempts:
2 left
💡 Hint

Check the --will-* options for QoS and retain flags.

Configuration
advanced
2:30remaining
Which MQTT broker configuration snippet correctly enables LWT with a retained message?

Given the following broker configuration options, which snippet correctly sets up LWT to publish a retained message when a client disconnects unexpectedly?

A
will_topic status/client
will_message offline
will_qos 1
will_retain true
B
last_will_topic status/client
last_will_message offline
last_will_qos 1
last_will_retain false
C
will_topic status/client
will_message offline
will_qos 0
will_retain false
D
last_will_topic status/client
last_will_message offline
last_will_qos 2
will_retain true
Attempts:
2 left
💡 Hint

Check the exact option names and retain flag value.

Troubleshoot
advanced
2:30remaining
Why does the LWT message not appear after unexpected client disconnect?

A client sets an LWT message, but when it disconnects unexpectedly, subscribers do not receive the LWT message. What is the most likely cause?

AThe client connected with clean session set to true
BThe LWT message was set with QoS 2
CThe broker does not support LWT
DThe client published a retained message before disconnect
Attempts:
2 left
💡 Hint

Consider how clean session affects session state and LWT delivery.

🔀 Workflow
expert
3:00remaining
Order the steps to correctly implement LWT in an MQTT client connection

Arrange the following steps in the correct order to implement Last Will and Testament (LWT) in an MQTT client connection.

A1,3,2,4
B2,1,3,4
C1,2,3,4
D2,3,1,4
Attempts:
2 left
💡 Hint

Think about configuration before connection, then broker behavior.