Keep alive
The MQTT server and client need to know whether each other is still online at all times; for example, for features such as last will to work. Every time a client publishes a message or subscribes to a topic, the server gets a life signal from the client. But what if the client does not send something for a while, or subscribes to a new topic? Under the hood, implemented by the MQTT library and server, ping packets are sent to let each other know that the connection is still stable and both are still online, ready to exchange messages.
If the server does not receive a life signal from a client, either via a normal publish/subscribe call or an empty ping message, the server will disconnect the client. When this happens, and the client ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access