TsgcSTUNClientEvents › OnSTUNResponseError

OnSTUNResponseError Event

Fires when the STUN server returns an error response; exposes the numeric Code and human-readable Reason.

Syntax

property OnSTUNResponseError: TsgcSTUNResponseErrorEvent;
// TsgcSTUNResponseErrorEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const aMessage: TsgcSTUN_Message; const aError: TsgcSTUN_ResponseError) of object

Default Value

Remarks

Called when the server answers a Binding Request with a STUN error response (for example 401 Unauthorized, 420 Unknown Attribute, 438 Stale Nonce). Read aError.Code and aError.Reason to diagnose the failure, and aMessage for the raw response. Authentication-related errors typically mean that STUNOptions.Authentication must be configured before retrying.

Example

procedure TForm1.oSTUNSTUNResponseError(Sender: TObject;
  const aSocket: TsgcSocketConnection; const aMessage: TsgcSTUN_Message;
  const aError: TsgcSTUN_ResponseError);
begin
  DoLog('Error: ' + IntToStr(aError.Code) + ' ' + aError.Reason);
end;

Back to Events