TsgcSTUNServerEvents › OnSTUNRequestError

OnSTUNRequestError Event

Raised before the server sends a STUN error response; allows the handler to inspect or suppress the reply.

Syntax

property OnSTUNRequestError: TsgcSTUNRequestErrorEvent;
// TsgcSTUNRequestErrorEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const aRequest: TsgcSTUN_Message; const aResponse: TsgcSTUN_Message; var Accept: Boolean) of object

Default Value

Remarks

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.

Example

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;

Back to Events