TsgcWebSocketLoadBalancerServer › Events › OnServerDisconnect
Fires when a backend server disconnects from the load balancer.
property OnServerDisconnect: TsgcWSLBServerDisconnectEvent;
// TsgcWSLBServerDisconnectEvent = procedure(Connection: TsgcWSConnection; Code: Integer) of object
—
OnServerDisconnect is raised when a registered backend server terminates its control channel with the load balancer. After the event returns the backend is removed from the pool and new client sessions will no longer be routed to it; existing client connections that were already proxied keep running until they end on their own. Code is the WebSocket close code (1000 for a clean close, 1006 for a broken socket). Typical uses are updating health dashboards, raising an alert, or triggering a reconnect from an external supervisor.
procedure OnServerDisconnect(Connection: TsgcWSConnection; Code: Integer);
begin
Log(Format('Backend disconnected: %s code=%d', [Connection.Guid, Code]));
end;