dotnet/MQTTnet

KeepAlive not triggering DisconnectEvent in due time

Opened this issue · 0 comments

Setup:

  1. Setup a hotspot with your smartphone
  2. Connect to the hotspot network with your MQTTNet client (ManagedClient, Websocket, TLS)
  3. Start the MQTTNet client and connect to a broker
  4. Disable the mobile data of the smartphone so that the hotspot is available but is not connected to the internet

KeepAlive is set to 5s.

Expected Behaviour:
After KeepAlive * 1.5 (= around 7-8s), the Disconnect-Event should be fired so that it can be handled.
(i.e. show a Connection-Lost screen)

Actual Behaviour:
After a random time (sometimes between 20-30s, sometimes never) the Disconnect-Event is fired and can be handled.

MQTTnet Version:

  • 4.3.7.1207

Component:

  • ManagedClient

We are running the MQTTnet client in the browser as a blazor wasm application.

Logs:
2024-11-18 11:33:24.293 +01:00 [WRN] MqttClient / Communication error while sending/receiving keep alive packets
2024-11-18 11:33:24.295 +01:00 [VRB] MqttClient / Stopped sending keep alive packets
2024-11-18 11:33:24.296 +01:00 [INF] MqttClient / Disconnected.
2024-11-18 11:33:24.299 +01:00 [VRB] MqttClient / Stopped receiving packets
2024-11-18 11:33:24.299 +01:00 [ERR] Disconnected with reason: NormalDisconnection

Note to Logs:
The entries appear in correct order but start later than the expected 7-8s.