TsgcWebSocketServer_HTTPAPI › Properties › HeartBeat
Sends periodic ping frames to keep idle WebSocket connections alive and detect dead peers.
property HeartBeat: TsgcWSHeartBeat_Options read GetHeartBeat write SetHeartBeat;
Enabled=False
When HeartBeat.Enabled is True the server sends a ping to every connected client every Interval seconds. Use Timeout to close peers that do not pong within the given number of seconds (0 disables the check). The OnBeforeHeartBeat event lets you replace the standard ping with a custom message by setting the Handled parameter to True. Heartbeats are especially important on cloud load balancers and NAT devices that silently drop idle TCP connections.
oServer := TsgcWebSocketServer_HTTPAPI.Create(nil);
oServer.HeartBeat.Interval := 30;
oServer.HeartBeat.Timeout := 0;
oServer.HeartBeat.Enabled := true;
oServer.Active := true;