# CREATING AN MQTT CONNECTION

The MQTT connector requires an existing MQTT Broker installed and configured upfront.

# Creating a Connection

MQTT over TLS v1.2 connection is the recommended protocol to use with MQTT Brokers. You need to create the connection prior to creating the flow. For more information, see 7 Creating a Connection instance. The creation of a connection establishes a link from ThingPark Wireless to the MQTT Broker that you want to associate a Device with. The link can be used to transport any Uplink regardless the DevEUI parameter. To do this, you need to use the following endpoints:

  • POST/connections for creation
  • PUT/connections for modification
  • DELETE/connections for deletion

Note

When you update a configuration property on a connection, you must provide the whole configuration properties again.

Example of the creation of a connection.

    POST /connections
    
    {
      "connectorId": "actility-mqtt-iot",
      "name": "Test MQTT (SSL) Connection",
      "configuration": {
        "description": "MQTT (SSL) connection example",
        "uplinkTopicPattern": "{profile}/mqtt/things/{DevEUI}/uplink",
        "downlinkTopicPattern": "{profile}/mqtt/things/{DevEUI}/downlink",
        "hostName": "91.134.250.109:8883",
        "protocol": "SSL",
        "username": "actility",
        "password": "actility",
        "certificate": "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----",
        "privateKey": "-----BEGIN RSA PRIVATE KEY-----...-----END RSA PRIVATE KEY-----"
      }
    }

The following table lists the expected results of the properties when applied.

Property Expected results
connectorId Expected results
configuration/uplinkTopicPattern Defines a pattern of topic for the Uplink.
configuration/downlinkTopicPattern Defines a pattern of topic for the Uplink.
configuration/hostName Hostname/IP and port of your MQTT Broker.
configuration/protocol Protocol to be used for the connection with your MQTT server, possible values are 'SSL' (MQTT over SSL), 'WSS' (MQTT over secure Web Sockets) or 'TCP' (MQTT over TCP without encryption).
configuration/username Login to access your MQTT Broker.
configuration/certificate Contents of the client certificate file (X.509 with .crt format only) used to connect to your MQTT server. Only required when you are using double factor authentication (login/password + client certificate).
configuration/privateKey Contents of the client private key file (PKCS#8 format only) used to connect to your MQTT server. Only required when you are using double factor authentication (login/password + client certificate).

# Displaying Information to Know if it Worked

  1. Download and install an MQTT client, for example MQTT.fx (opens new window).
  2. Create a new connection and connect to the MQTT Broker using your configuration:

img
img

3. Select “Subscribe” tab, fill the uplink topic you want to monitor (that is, loopBackTool/mqtt/things/78AF580300000345/uplink) and click Subscribe.

img

You should see incoming uplinks in the right part of the screen.

Last Updated: 1/12/2021, 6:02:10 PM