TsgcWSPClient_MQTT属性 › Authentication

Authentication 属性

在 MQTT CONNECT 数据包中发送用户名和密码,以针对代理验证客户端身份。

语法

property Authentication: TsgcWSMQTTAuthentication_Options read FAuthentication write SetAuthentication;

默认值

Enabled=False

备注

默认情况下身份验证处于禁用状态。将 Authentication.Enabled 设为 True,并分配 UserNamePassword,即可在发送给代理的 CONNECT 数据包中包含 MQTT 用户名和密码字段。凭据在 MQTT 层携带,与底层 WebSocket 传输无关:当 Active 设为 True 时,客户端通过附加的 Client(或通过 Broker 的原始 TCP)打开 WebSocket,然后使用提供的凭据发送 MQTT CONNECT。对于 MQTT 5.0 扩展身份验证(质询/响应),请结合 ConnectPropertiesAuthenticationMethod 字段与 Auth 方法使用。

示例


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;

返回属性