Hello,
We have a problem with our TMS MQTT client, it sporadically loses the connection to the MQTT broker. The client is configured like this:
FMessagingClient.ClientID := p_Configuration.ClientId;
FMessagingClient.Credentials.Username := p_Configuration.AuthenticationUsername;
FMessagingClient.Credentials.Password := p_Configuration.AuthenticationPassword;
FMessagingClient.KeepAliveSettings.AutoReconnect := true;
FMessagingClient.KeepAliveSettings.AutoReconnectInterval := 10;
FMessagingClient.LastWillSettings.Topic := FLastWillTopic;
FMessagingClient.LastWillSettings.WillMessage := Format('{"clientId":"%s"}', [p_Configuration.ClientId]);
FMessagingClient.OnConnectedStatusChanged := ClientOnConnectedStatusChanged;
FMessagingClient.OnPublishReceived := ClientOnPublishReceived;
FMessagingClient.BrokerHostName := p_Configuration.Hostname;
FMessagingClient.BrokerPort := p_Configuration.Port;
FMessagingClient.Connect();
Because of a timeout, the broker disconnects our client. Sometimes reconnecting works, sometimes it doesn't.
In case of an error, our client keeps trying to reconnect. However, there is no activity visible in the login on the broker side. We have tested two different brokers (Mosquitto and EMQX), both with the same behavior. Is it possible that there is an error in the TMS MQTT client?
We have attached the following log files:
Exception when the timeout occurs:
bugreport_2024-10-02_22.50.09.txt (92.9 KB)
Client side logging:
TMS Mqtt.log (907.9 KB)
Broker side logging:
mosquitto log.txt (1.3 MB)
Thank you for any help!
It is hard to judge from the log files. These seem out of sync between the mosquitto log and the MQTT Client log.
In the MQTT client log, I see no disconnect, I see it keeps doing keep-alive PING requests.
So, to begin with, are these the proper logs? Is this the latest MQTT client version? Is this when running the app outside the Delphi IDE in release mode?
We are using TMS MQTT client 2.0.8. The error occurs in the release version. I have not tested it from Delphi IDE yet.
Yes, you are right, the Mosquitto log is not synchronized with the other log files (the Mosquitto log is from a customer, the other one we created in our office). I will repeat the test and provide you with the correct logs. Because the error is hard to reproduce, it may take a while.
Attached you will find the log files from the TMS MQTT Client and the MQTT Broker (EMQX). The log files are now synchronized with each other.
I have recorded two cases:
-
The MQTT broker is manually shut down and then restarted. The client reports the connection interruption as expected and automatically reconnects to the broker as soon as it is available again. (see Reconnection successful.zip)
-
The MQTT broker cuts the connection to the client because it has not responded for too long. Nothing is sent for over 3 minutes, not even a PINGREQ. The broker then closes the connection to the client. The subsequent reconnect attempt no longer seems to work. (see Reconnection failed.zip)
Reconnection successful.zip (5.4 KB)
Reconnection failed.zip (11.4 KB)
I hope this information helps you to find our problem.
Hello again,
Did you have the time to check or even reproduce our issue? Any news on that problem?
Thank you and best regards
I'd be interested in any information on this topic as well, as I might see similar behaviour. I'm using version 2.0.8.0
Regards,
Leif Eirik
We see from the log files that v2.0.2.1 was used but we made already several improvements in the latest version v2.0.8.0, so can you please first check this with the latest version? If a problem persists, please provide use with the log files generated with v2.0.8.0