MQTT

To configure a Publisher or Subscriber to use MQTT transport, simply open the Publisher/Subscriber configuration page and select the MQTT transport. MQTT supports the (binary) UADP encoding as well as JSON and may be configured with a specified header layout.

Encoding

There are two encodings available for selection: MQTT/UADP and MQTT/JSON. The first data format uses the binary UADP encoding to encode messages and the last one uses a JSON format.

MQTT 1:

Depending on the selected header layout, the MQTT/JSON encoding may look as follows:

{
  "MessageId": "{0CF7F27A-56FF-1F85-CFC2-12C886365C1D}",
  "MessageType": "ua-data",
  "Messages": [
    {
      "DataSetWriterId": 1,
      "Payload": {
        "nCounter": {
          "Type": 4,
          "Body": 18
        },
        "bToogle": {
          "Type": 1,
          "Body": false
        }
      }
    },
    {
      "DataSetWriterId": 2,
      "Payload": {
        "myNewVariable": {
          "Type": 4,
          "Body": 42
        }
      }
    }
  ]
}

The JSON format is standardized within the OPC UA Pub/Sub specification. For a full description of the JSON scheme and each individual field, please consult the specification.

Connection parameters

Whenever using MQTT as the transport protocol, you also need to define connection parameters to the MQTT Message Broker. These parameters can be specified, depending on the use case, in two different locations:

The following screenshot shows the MQTT connection parameters on a Publisher:

MQTT 2:

The following screenshot shows where to set up the global MQTT connection on the OPC UA RT device:

MQTT 3:

In both cases, the dialog that allows to enter the connection parameters is the same and looks as follows:

MQTT 4:

Topics

Data on the MQTT Message Broker is organized in so-called “topics”. From an OPC UA Pub/Sub point-of-view, you can specify topics on two layers: