Track connected clients on embedded mqtt broker

Hi all,
I have some devices (nodemcu) that are connected through mqtt and sometimes this devices drop connection or stop reporting for many reasons. I couldn’t find solution for monitoring MQTT clients and checking if they are online. So I created small Plugin for HBMQTT that publishes messages when client is connected and disconnected. May be this will help some of you. If you have better solution, please share.
Code is here: https://github.com/masarliev/hbmqtt_device_tracker with installation instructions and configuration

This is normally done through the will message. When a client connects, it specifies a will topic and message. When the client disconnects, the broker sends the will topic message to all clients that have subscribed to it.

HBMQTT don’t send will messages. Tested with version 0.8 (current HA) and latest. May be problem is there because will messages work on mosquito. How I test it. each command is in separate window

hbmqtt # start the broker
hbmqtt_sub --url mqtt://127.0.0.1 -t '#'  --will-topic 'will/c1' --will-message 'out'
hbmqtt_pub --url mqtt://127.0.0.1 -t 'state' -m 'on' --will-topic 'will/c2' --will-message 'out'

Ah, I didn’t understand that you were working around the inadequacies of the broker. I think you should make that clear in your initial post, as newcomers might think that this was the standard way of doing things.

Or just use mosquitto as the broker, which does the protocol properly to start with.