MQTT¶
Characteristics - MQTT¶
MQTT is an OASIS standard messaging protocol for the Internet of Things (IoT). To learn more about the standard visit the MQTT website.
Information Model Requirements
The first node after the root node, , must be of type Event or Variables with a Simple Data Type.
The following Node Types can be used under the Event Node:
Variables with a Simple Data Type represents the key-value pairs.
Variables with a Custom Data Type represent objects that can contain key-value pairs.
With Lists you can aggregate multiple variables.
Hint
When publishing a topic, the Information Model dictates the payload’s structure.
Hint
When subscribing to a topic, ensure that the Information Model structure aligns with the payload.
Configuration - MQTT Channel¶
Select the MQTT (JSON) as Channel Type.
Click the Configure button.
Select the root model node
Configure the MQTT To String configuration:
Enter Host and Port of the MQTT Broker used
If required, adjust the default values for Reconnect interval, Connection timeout, Keep alive interval and the Unit for each
Specify a path to a folder on your local machine. The temp directory inside the SMARTUNIFIER Manager can be used as well.
(Optional) Specify a Client ID
Set the Quality of Service (QoS)
(Optional) Enable Retained if required
Select Username and password in order to manually enter the credentials or select Username and password credentials reference to add it from the Credentials Manager. If there are no credentials needed (e.g.,
test.mosquitto.org
) select None.
Select the event node in the tree on the left.
Enable either Producer or Consumer depending on the use case and enter a Topic name.
Click the Apply button.
Note
The Producer and Consumer options can be enabled for a Variable node, allowing it to produce or subscribe to/from a single variable.
Variable Configuration
This configuration can be used when certain keywords or reserved words from the data set are not allowed in the Information Model. For example, for the Scala keywords like ‘type’, you might name it ‘Type’ in the Information Model. Subsequently, in the Channel configuration, you can assign its actual name using the Field name input.
To configure the field name follow the steps described below:
Select a variable in the tree on the left.
Check the box for the Variable configuration.
Input the Field name, representing the reserved word.
Click on the Apply button.
Certificates
Encrypted connection using TLS security is supported. Follow the steps below to encrypt the connection.
Enable Hostname Verification (optional)
Enable the Tls Configuration checkbox
Enter the path to the CA (certificate authority) certificate of the CA that has signed the server certificate
Note
Make sure the CA certificate is valid.
Enable the Client checkbox
Enter the path to the Client certificate. The client certificate identifies the client just like the server certificate identifies the server.
Enter the path to the Private client key.
If applicable select to enter a Password or to add from the Credentials Manager.
Select the Protocol from the Drop-Down.
Disconnected Buffer
In case the connection is lost, messages can be buffered offline when the Disconnected Buffer is enabled. Follow the steps below to enable the DisconnectedBuffer.
Enable the Disconnected Buffer checkbox.
Set the Buffer size - defines the number of messages being hold e.g., 5000.
(Optional) Enable Persist Buffer.
(Optional) Enable Delete Oldest Message.
Description of configuration properties:
Property |
Description |
Example |
---|---|---|
host |
URL of the MQTT Broker. |
|
port |
Port of the MQTT Broker. |
|
reconnectInterval |
Time interval to reconnect to the MQTT Broker after loss of connection in seconds |
|
connectionTimeout |
Time interval the connection times out in seconds |
|
keepAliveInterval |
Time the session persists in seconds |
|
persistenceFolder |
Path to a folder for the persistence store of the MQTT |
|
clientId |
Identifies an MQTT client which connects to an MQTT Broker |
|
username |
Client username |
|
password |
Client password |
|
hostnameVerification |
Hostname Verification |
|
tls |
Encryption |
|
producers |
Data producer |
|
consumer |
Data consumer |
|
protocol |
TLS protocol version |
|
disconnectedBuffer |
Offline buffering of data |
|
bufferSize |
Amount of message allowed in the buffer |
|
persistBuffer |
Buffer persistence |
|
deleteOldestMessage |
Delete oldest message in buffer |
|