TsgcSTUNServer › Events › OnSTUNRequestError
Raised before the server sends a STUN error response; allows the handler to inspect or suppress the reply.
property OnSTUNRequestError: TsgcSTUNRequestErrorEvent;
// TsgcSTUNRequestErrorEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const aRequest: TsgcSTUN_Message; const aResponse: TsgcSTUN_Message; var Accept: Boolean) of object
—
Fired when the server has built a Binding Error Response (for example 400 Bad Request, 401 Unauthorized, 420 Unknown Attribute or 438 Stale Nonce) and is about to send it back to the client. Inspect aRequest / aResponse — in particular the ERROR-CODE attribute of aResponse — to log the failure reason. Set Accept := False to drop the datagram and leave the client without a reply, which can be useful to avoid amplification when repeated invalid requests arrive from the same source. The handler runs on the listener thread unless NotifyEvents selects another mode.
procedure TForm1.OnSTUNRequestError(Sender: TObject;
const aSocket: TsgcSocketConnection; const aRequest: TsgcSTUN_Message;
const aResponse: TsgcSTUN_Message; var Accept: Boolean);
begin
Memo1.Lines.Add('STUN error for ' + aSocket.PeerIP);
Accept := True;
end;