TsgcWSPClient_MQTTProperties › Client

Client Property

References the TsgcWebSocketClient that carries MQTT frames when connecting over WebSockets.

Syntax

property Client: TsgcWSComponent_WSClient read FClient write SetClient;

Default Value

nil

Remarks

Drop a TsgcWebSocketClient on the form and assign it to Client to run MQTT over WebSockets. The WebSocket client manages the transport (host, port, TLS, proxy, HTTP headers and subprotocol negotiation) while this component implements the MQTT packet layer on top. After assignment the MQTT client connects automatically when the WebSocket handshake completes: set the host/port on the TsgcWebSocketClient and Active := True. Brokers that support MQTT over WebSocket usually listen on port 8000 (plaintext) or 8084 (TLS) and advertise mqtt as the WebSocket subprotocol. Use Broker instead when you need raw TCP.

Example


WSClient := TsgcWebSocketClient.Create(nil);
WSClient.Host := 'broker.hivemq.com';
WSClient.Port := 8000;
MQTT := TsgcWSPClient_MQTT.Create(nil);
MQTT.Client := WSClient;
WSClient.Active := True;

Back to Properties