emqx / MQTTX

A Powerful and All-in-One MQTT 5.0 client toolbox for Desktop, CLI and WebSocket.

Home Page:https://mqttx.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Not sending Keep-alive

arturv2000 opened this issue · comments

What did I do

MQTTX periodically "forget" to send the keep-alive to the broker. The interval that it happens is not always the same.

I have a connection to a broker, and defined the keep-alive to 60 seconds, no special error appears on the log file except indication that the connection was terminated.

Broker is an NanoMQ instance, Version: v0.21.6-6.

Have other clients connected (using Node-Red, MQTT.JS) and there are no issues with those connections, some running on the same machine as MQTTX.

What happened

Connection is terminated by broker since no Kepp-Alive message is sent to broker.

Expected

MQTTX should always send the keep-alive to broker according to configured interval.

Environment

  • OS: OS version, Windows 11 22631.3235
  • MQTTX version, v1.9.9

More detail

More detail include log information or screenshot

[2024-03-04 11:06:45] [INFO] Message arrived for FDR_Server with topic: "maquina/WHDNGDEV01-VNT/ACM". Message ID: "message_66093020-4147-4592-b374-b3679f3b13ff", payload: "{\"RDY\":0,\"FMW\":\"02.10\",\"RES\":0,\"ATY\":0,\"POS\":0,\"EFF\":4,\"ERR\":0,\"VAL\":0,\"CAB\":-1,\"BAT\":34,\"SRL\":\"00220400064\",\"DEV\":\"ACM\",\"PRT\":\"/dev/ttyUSB0\",\"IFW\":false,\"HTS\":1}". MQTT.js onMessageArrived trigger
[2024-03-04 11:06:45] [INFO] The connection FDR_Server (clientID mqttx_4a65da5f) is offline. MQTT.js onOffline trigger
[2024-03-04 11:06:45] [INFO] Connection for FDR_Server closed, MQTT.js onClose trigger
[2024-03-04 11:06:49] [INFO] Retrying connection for FDR_Server, attempt: 4

Screenshot from Wireshark
image

Thank you for reporting the issue with MQTTX not sending Keep-Alive messages as expected in version v1.9.9. To help troubleshoot, you can enable debug logs to observe the ping requests, giving insights into what happens when the requests stop being sent.

image

The connection dropping after the application has been idle is a known issue related to MQTTX being built on Electron, where MQTT connections are managed at the UI layer rather than through Node.js. This can result in a different experience compared to tools like Node-Red. We're addressing this in the upcoming 2.0 release to prevent tab freezing and disconnection due to inactivity.

In the meantime, for a stable, long-term connection, consider using MQTTX CLI, which doesn't have this issue but lacks a GUI. Alternatively, enabling the desktop version's auto-reconnect feature may help by immediately attempting to reconnect after disconnection.

Thanks for the feedback.

Already have the auto-reconnect enabled, but sometimes it will give-up the reconnections attempt, but need to check if it is any issue with the broker (NanoMQ).

Will wait for release of v2.0 to check if it is OK.