TsgcHTTP2Client › 属性 › HeartBeat
定期发送 HTTP/2 PING 帧以保持连接活跃。
property HeartBeat: TsgcTCPHeartBeat_Options read FHeartBeat write SetHeartBeat;
Enabled=False
当 HeartBeat.Enabled 为 True 时,客户端每隔 Interval 秒发送一个 HTTP/2 PING 帧,以通过代理和 NAT 设备保持连接活跃。HeartBeatType 选择策略:hbtAlways 在每个间隔发送 ping,而 hbtOnlyIfNoMsgRcvInterval 仅在最后一个间隔内未收到数据时发送 ping。此功能对于用于流式传输或服务器推送的长连接 HTTP/2 连接特别有用。
oHTTP2 := TsgcHTTP2Client.Create(nil);
oHTTP2.Host := 'http2.akamai.com';
oHTTP2.Port := 443;
oHTTP2.TLS := True;
oHTTP2.HeartBeat.Interval := 30;
oHTTP2.HeartBeat.Enabled := True;