TsgcWSAPIServer_WebPush › 事件 › OnWebPushSendNotificationException
向推送服务发送通知的 POST 请求引发异常时触发(典型原因:400 Bad Request、过期端点的 404/410 Gone、TLS 或网络故障)。
property OnWebPushSendNotificationException: TsgcWSWebPushSendNotificationException;
// TsgcWSWebPushSendNotificationException = procedure(Sender: TObject; aSubscription: TsgcHTTP_API_WebPush_PushSubscription; E: Exception; var Remove: Boolean) of object
—
从 SendNotification 和 BroadcastNotification 内部的按订阅者循环中引发。Remove 变量参数默认为 True:保持原样会从内部列表中删除有问题的订阅(对于永久性失败如 HTTP 410 Gone 这是正确的行为)。将其设置为 False 可保留订阅并稍后重试。使用 E 进行日志记录和诊断。
procedure TForm1.sgcWSAPIServer_WebPush1WebPushSendNotificationException(
Sender: TObject; aSubscription: TsgcHTTP_API_WebPush_PushSubscription;
E: Exception; var Remove: Boolean);
begin
LogError(aSubscription.Endpoint, E.Message);
// keep subscription on transient errors, remove it on permanent ones
Remove := Pos('410', E.Message) > 0;
end;