Fundamental Features of MQTT | Set 3 Last Updated : 15 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report Prerequisites – Message Queue Telemetry Transport Protocol (MQTT) Fundamental Features of MQTT | Set 1 Fundamental Features of MQTT | Set 2 Last Will and Testament : In MQTT, publisher client publishes messages on specific topic to Broker. The broker then publishes these messages to clients subscribed to that topic. If the publisher/subscriber client wants to end connection with broker, it sends DISCONNECT message. In this way, communication can be disconnected gracefully. But there are several scenarios in which client might get disconnected abruptly. In such case, client ends communication with broker without sending DISCONNECT message. In such scenarios, other clients will not be informed about failure and hence they will keep waiting for messages from disconnected client. A client could get disconnected abruptly due to any of following reasons - Failure of underlying network due to loss of connection or hardware failure. Failure to send message within keep-alive period. To solve such problem, concept of last will messages is used. Using this feature, client provides predefined will message when it first gets connected to broker. This message is stored by the broker. If the client disconnects abruptly, broker will publish will message on will topic for all subscribed clients. If the client disconnects gracefully, broker will discard will message. LWT message and LWT topic : LWT message defines message to be published as last will to subscribed clients. LWT topic defines topic on which last will message will be published. Figure - Last Will and Testament Example - Figure - Mosquitto Illustration of Last Will and Testament In the above illustration, will topic is "sensor/status" and will message is "offline". Once client disconnects abruptly, socket error is displayed on mosquito broker terminal. Hence broker then sends will message "offline" to client subscribed to topic "sensor/status". Mosquitto Commands : Last Will Topic (mandatory) - If no other parameters are provided, then publishing only last will topic will publish non-retained, zero-length message with QoS0 to subscribed clients. --will-topic Last Will Message (optional) - Defaults to an empty message of zero length. --will-payload Last Will QoS (optional) - Defaults to QoS0. --will-qos Last Will Retain (optional) - Defaults to retain false. --will-retain Create Quiz Comment D devshreebharatia Follow 1 Improve D devshreebharatia Follow 1 Improve Article Tags : Computer Subject Computer Networks Explore Computer Network BasicsBasics of Computer Networking4 min readTypes of Computer Networks6 min readIntroduction to Internet5 min readNetwork Devices4 min readWhat is OSI Model? - Layers of OSI Model11 min readTCP/IP Model6 min readOSI and TCP/IP Model4 min readPhysical LayerPhysical Layer in OSI Model3 min readTypes of Network Topology9 min readTransmission Modes3 min readTransmission Media in Computer Networks7 min readData Link LayerData Link Layer in OSI Model4 min readSwitching | Computer Networks2 min readVirtual LAN (VLAN)3 min readFraming in Data Link Layer3 min readError Control in Data Link Layer3 min readFlow Control4 min readPiggybacking in Computer Networks2 min readNetwork LayerNetwork Layer in OSI Model3 min readIntroduction of Classful IP Addressing7 min readClassless Addressing in IP Addressing7 min readWhat is an IP Address?11 min readIPv4 Datagram Header4 min readDifference Between IPv4 and IPv63 min readPublic and Private IP addresses4 min readIntroduction To Subnetting5 min readWhat is Routing?10 min readNetwork Layer Protocols9 min readTransport LayerTransport Layer in OSI Model4 min readTransport Layer Protocols9 min readTransmission Control Protocol - TCP4 min readUser Datagram Protocol - UDP3 min readSession Layer & Presentation LayerSession Layer in OSI model2 min readPresentation Layer in OSI model2 min readSecure Socket Layer (SSL)4 min readPoint-to-Point Tunneling Protocol - PPTP2 min readMultipurpose Internet Mail Extension (MIME) Protocol3 min readApplication LayerApplication Layer in OSI Model4 min readClient-Server Model3 min readWorld Wide Web (WWW)5 min readIntroduction to Electronic Mail4 min readWhat is a Content Distribution Network and how does it work?4 min readProtocols in Application Layer4 min readAdvanced TopicsWhat is Network Security?4 min readQuality of Service and Multimedia5 min readAuthentication in Computer Network3 min readEncryption, Its Algorithms And Its Future6 min readIntroduction of Firewall in Computer Network3 min readMAC Filtering in Computer Network3 min readWi-Fi Standards Explained2 min readWhat is Bluetooth?6 min readGenerations of wireless communication2 min readCloud Networking4 min readPracticeTop 50 Plus Networking Interview Questions and Answers15+ min readTop 50 TCP/IP Interview Questions and Answers 202515+ min readNetwork Fundamentals Interview Questions - Computer Networks15+ min readLast Minute Notes for Computer Networks14 min readComputer Network - Cheat Sheet15+ min read Like