TsgcWSAPIServer_WebPushイベント › OnWebPushSendNotificationException

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

デフォルト値

解説

SendNotificationBroadcastNotification 内のサブスクライバーごとのループの両方から発生します。Remove varパラメータはデフォルトで True です。そのままにしておくと、問題のあるサブスクリプションが内部リストから削除されます(HTTP 410 Goneなどの永続的な失敗に対して適切な動作です)。失敗が一時的な場合(ネットワークタイムアウト、プッシュサービスからの5xx)にサブスクリプションを保持して後でリトライするには 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;

イベントに戻る