exception when connection is closed

If connection is closed from network problem, I have a lot of exceptions in the following line:
File: TMS.MQTT.Connection, line 267

        if FIdTcpClient.Socket.InputBufferIsEmpty then

that it is called from file TMS.MQTT.Client.Threading line 548

        // check if we have incoming data:
        while (FConnection.HasData) do

Is it possible to ckeck state and validity of object before trying to access it?

The stack follows:
Exception OS: 20230131 06475525 # EXCOS EAccessViolation (c0000005) [] at 013028d5
TMS.MQTT.Connection.pas TTMSMQTTNetworkConnection.HasData (267)
TMS.MQTT.Connection.pas TTMSMQTTNetworkConnection.HasData (286)
TMS.MQTT.Client.Threading.pas TTMSMQTTReaderThread.Work (548)
TMS.MQTT.Client.Threading.pas TTMSMQTTWorkerThread.Execute (636)

I do not know if it helps but before the above exception, a previous exception has the following stack:
Exception: 20230131 06474523 " EXC EIdConnClosedGracefully {Message:"Connection Closed Gracefully."} [] at 012d21d0
IdIOHandler.pas TIdIOHandler.RaiseConnClosedGracefully (2154)
IdIOHandler.pas TIdIOHandler.RaiseConnClosedGracefully (2154)
IdIOHandlerStack.pas TIdIOHandlerStack.CheckForDisconnect (467)
IdIOHandler.pas TIdIOHandler.Write (2497)
TMS.MQTT.Connection.pas TTMSMQTTNetworkConnection.Write (421)
TMS.MQTT.Client.Threading.pas TTMSMQTTWriterThread.HandlePacketQos0 (483)
TMS.MQTT.Client.Threading.pas TTMSMQTTWriterThread.Work (511)
TMS.MQTT.Client.Threading.pas TTMSMQTTWorkerThread.Execute (636)

We investigated this and it is a kind of hard to reproduce. But based on the information here, we made some adaptions and released a new beta. Can you test with this beta?

1 Like