MQTT Client
MQTT Client
MQTTClient Component
MQTTClient component must be added to the CDP system in order to connect and interact with other devices in the MQTT network.
MQTTClient has the following configurable properties:
Property | Description |
---|---|
BrokerHost | Broker host to connect to (IP address or hostname). |
BrokerPort | Broker TCP port (usually 1883 for unencrypted and 8883 for encrypted connections) |
UserID | User ID for authentication with the broker. Can be empty if the broker allows connections without userID. |
Password | Password for authentication with the broker. Can be empty if the broker allows connections without the password. |
ClientID | Client ID to use when connecting to the broker. If empty, a random (but same for every component instance on every start) ClientID will be auto-generated. |
KeepAlive | Connection keep-alive interval in seconds. The keep-alive functionality assures that the connection with the broker is still open. Defaults to check it after every 60 seconds. |
Retry | Connection retry in seconds. Sets the time to wait between unsuccessful connection retries. Defaults to 10 seconds. |
LWTTopic | LWT (Last Will and Testament) topic that can be used by other clients to detect this client's connectivity. |
LWTConnectedPayload | Payload that will be sent to LWTTopic at client connect. |
LWTDisconnectedPayload | Payload that will be sent to LWTTopic by the broker after this client connection is lost. |
Encryption | Broker connection encryption. Choose between options:
|
TLSBrokerCACertFile | Broker host certificate issuer (CA) file name (used for TLS certificate-based broker verification). See also TLS certificate setup. |
TLSBrokerVerification | Broker TLS connection verification method flags: when flag H is set, then the client will check that the broker hostname matches the certificate; when flag C is set - then the client will check that the broker certificate is signed using the CA set in TLSBrokerCACertFile. By default, both checks are turned on. |
TLSClientCertFile | Client authentication certificate file name (for TLS client authentication). See also TLS certificate setup. |
TLSClientKeyFile | Client authentication key file name (for TLS client authentication). See also TLS certificate setup. |
TLSPSKIdentity | TLS-PSK key identity (for TLS-PSK-based encryption/authentication). See also TLS-PSK key setup. |
TLSPSKKey | TLS-PSK key hexadecimal string (for TLS-PSK-based encryption/authentication). See also TLS-PSK key setup. |
DisablePersistentSessions | Flag to be used for connecting with some MQTT brokers (f.e. AWS) that actively refuse connections with MQTT persistent session facility enabled (cleanSession=false). PS! Be aware that setting DisablePersistentSessions also means that messages received by the broker during client connection failure will not be resent at connection restore (regardless of sender QoS parameter). |
ProtocolVersion | MQTT protocol version to use. Choose between:
|
MQTTClient state can be observed at runtime via these read-only properties:
Connected | Connection status with the broker. |
ConnectionLastChangedTime | The timestamp of the last connection or disconnection. |
LastMessageTime | The timestamp of the last message sent or received. |
PublishedMessageTotalCount | Sent (published) message total count for all topics. |
SubscribedMessageTotalCount | Received (subscribed) message total count for all topics. |
BrokerMaxTopicAlias | Maximum number of MQTT v5 topic aliases allowed, that the broker informed during connect handshake |
UsedAliasesCount | MQTT v5 topic aliases currently in use |
To send/receive data to/from the MQTT network, there are two different possibilities:
- Topics can be added to the MQTTClient that will send/receive data to/from signal-channels.
- Publisher and Subscriber Sequencer blocks can be added and connected to the MQTTClient to send/receive data using Sequencer Events.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.