Reconnection thread do not stop even if TMSMQTTClient.Disconnect() is invoked.


When I set the KeepAliveSettings.AutoReconnect to TRUE and the connection drops for any reason, the reconnection thread comes and start trying to reconnect. Ok so far. But, when I call Disconnect() the thread keeps running and trying to reconnect!

I found this logic inside unit TMS.MQTT.Client.pas, line 716 of client version, on method TMSMQTTClient.Disconnect():

if not (ConnectionStatus = csConnect) then

// ... after this check guard, the reconnection thread is stopped. 
// But, the stop logic is never
// reached because ConnectionStatus IS NOT csConnect at this moment!

So, this peace of code shouldn't be like this?

if ConnectionStatus = csNotConnected then

// Now, the reconnection stop logic will be reached!

Changing this by my own fixed this issue. I'm posting this here to see if the original code is the desired way or not and to help others with the same problem.