danieleteti / delphistompclient

STOMP client for Embarcadero Delphi and FreePascal.
141 stars 64 forks source link

Function Connected not working when connection was closed unexpectedly #36

Open ronaldobim opened 1 year ago

ronaldobim commented 1 year ago

To simulate the problem, use the TCPView tool to close the connection once the StompClient is connected. To solve the problem I just added a try..except. Because de function fails, I can't use method Disconnect to force a new connection. TCPView.zip

OBS: I'm not use Synapse

function TStompClient.Connected: boolean; begin try {$IFDEF USESYNAPSE} Result := Assigned(FSynapseTCP) and FSynapseConnected;

{$ELSE} // ClosedGracefully <> FTCP.Connected !!! Result := Assigned(FTCP) and FTCP.Connected and (not FTCP.IOHandler.ClosedGracefully); {$ENDIF} except Result := False; end; end;