TsgcWSPClient_MQTTProperties › Authentication

Authentication Property

Sends a UserName and Password in the MQTT CONNECT packet to authenticate the client against the broker.

Syntax

property Authentication: TsgcWSMQTTAuthentication_Options read FAuthentication write SetAuthentication;

Default Value

Enabled=False

Remarks

Authentication is disabled by default. Set Authentication.Enabled to True and assign UserName and Password to include the MQTT Username and Password fields in the CONNECT packet sent to the broker. The credentials are carried at the MQTT layer and are independent from the underlying WebSocket transport: when Active is set to True the client opens the WebSocket via the attached Client (or raw TCP via Broker) and then sends MQTT CONNECT with the supplied credentials. For MQTT 5.0 extended authentication (challenge/response), use the AuthenticationMethod field of ConnectProperties together with the Auth method.

Example


MQTT := TsgcWSPClient_MQTT.Create(nil);
MQTT.Client := WSClient;
MQTT.Authentication.Enabled := True;
MQTT.Authentication.UserName := 'your user';
MQTT.Authentication.Password := 'your password';
WSClient.Active := True;

Back to Properties