TsgcTURNServer › Events › OnSTUNRequestError
Raised before the server sends a STUN/TURN 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 an error response (for example 400 Bad Request, 401 Unauthorized, 403 Forbidden, 437 Allocation Mismatch, 438 Stale Nonce, 441 Wrong Credentials, 442 Unsupported Transport Protocol, 486 Allocation Quota Reached, 508 Insufficient Capacity) 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('TURN error for ' + aSocket.PeerIP);
Accept := True;
end;