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

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

  1. Select the MQTT (JSON) as Channel Type.

  2. Click the Configure button.

MqttConfiguration
  1. Select the root model node

  2. 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.

MqttModelRootNodeConfiguration MqttModelRootNodeConfiguration
  1. Select the event node in the tree on the left.

  2. Enable either Producer or Consumer depending on the use case and enter a Topic name.

  3. Click the Apply button.

MqttModelEventNodeConfiguration

Note

The Producer and Consumer options can be enabled for a Variable node, allowing it to produce or subscribe to/from a single variable.

MqttModelVariableNodeConfiguration

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:

  1. Select a variable in the tree on the left.

  2. Check the box for the Variable configuration.

  3. Input the Field name, representing the reserved word.

  4. Click on the Apply button.

MqttModelVariableConfiguration

Certificates

Encrypted connection using TLS security is supported. Follow the steps below to encrypt the connection.

  1. Enable Hostname Verification (optional)

  2. 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.

  1. 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.

Mqtt Configuration Certificates

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.

  1. Enable the Disconnected Buffer checkbox.

  2. Set the Buffer size - defines the number of messages being hold e.g., 5000.

  3. (Optional) Enable Persist Buffer.

  4. (Optional) Enable Delete Oldest Message.

MqttConfigurationDisconnectedBuffer

Description of configuration properties:

Property

Description

Example

host

URL of the MQTT Broker.

test.mosquitto.org

port

Port of the MQTT Broker.

1883

reconnectInterval

Time interval to reconnect to the MQTT Broker after loss of connection in seconds

5

connectionTimeout

Time interval the connection times out in seconds

60

keepAliveInterval

Time the session persists in seconds

60

persistenceFolder

Path to a folder for the persistence store of the MQTT

temp

clientId

Identifies an MQTT client which connects to an MQTT Broker

MyClientID

username

Client username

Username

password

Client password

Password

hostnameVerification

Hostname Verification

true, false

tls

Encryption

true, false

producers

Data producer

true, false

consumer

Data consumer

true, false

protocol

TLS protocol version

TLSv1.1, TLSv1.2

disconnectedBuffer

Offline buffering of data

true, false

bufferSize

Amount of message allowed in the buffer

5000

persistBuffer

Buffer persistence

true, false

deleteOldestMessage

Delete oldest message in buffer

true, false