I used LWT MQTT in my app.
As a rule, On close app or disconnect the network, the LWT should word immediately but not working or if working, send will message after many minutes
I use SetWill on initializing MQTT and set QOS to 1 and retain true
Please help me with it