TsgcWebSocketClientEvents › OnError

OnError Event

Fires every time a WebSocket protocol error occurs on the connection.

Syntax

property OnError: TsgcWSErrorEvent;
// TsgcWSErrorEvent = procedure(Connection: TsgcWSConnection; const Error: string) of object

Default Value

Remarks

OnError reports protocol-level problems detected by the WebSocket layer, such as an invalid message type, a malformed frame, or an invalid UTF-8 payload when Options.ValidateUTF8 is enabled. The Error parameter contains a textual description of the failure; the Connection parameter identifies the affected session. For unhandled exceptions (socket errors, access violations...) use OnException instead. This event does not close the connection by itself.

Example


procedure OnError(Connection: TsgcWSConnection; const Error: string);
begin
  WriteLn('#error: ' + Error);
end;

Back to Events