MQTT channel

"MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium." [1]

At InteliGlue® MQTT Data Clients are designated for real time protocol data streaming of any sensoric devices, actuators, field gateways etc.

Streaming data to InteliGlue®

To stream data up or down to InteliGlue® Data Account and MQTT Data Client are required. MQTT client can be configured/restricted to subscribe or publish particular topics due to security reasons.

  • Host: mqtt.inteliglue.com:<<assigned-port>>
  • Topic: <<data-account-root-name>>/any/custom/topic

InteliGlue® supports MQTT over WebSockets too. WebSockets connection is on specific port, make sure, that you always add the /mqtt path.

  • Websockets host: wss://mqtt.inteliglue.com:<<websockets-port>>/mqtt

For MQTT a wide range of software clients exists, that can be used to integrate with MQTT, see [2]. For testing and debuging purposes you can use mqttfx.

Connection to InteliGlue® MQTT Broker is encrypted by TLSv1.2 using the LetsEncrypt CA certificate.

NodeJS MQTT client example

For NodeJS you can use MQTT library https://www.npmjs.com/package/mqtt, just install the package using npm install mqtt --save to your project.

'use strict';

const mqtt = require('mqtt');
const fs = require('fs');
const TRUSTED_CA_LIST = fs.readFileSync(__dirname + '/cert/DST_Root_CA_X3.pem');

const options = {
  host: 'mqtt.inteliglue.com',
  port: 12345,
  protocol: 'mqtts',
  username: 'clientusername',
  clientId: 'clientusername', // clientId same as username
  password: 'clientpassword',
  rejectUnauthorized : true,
  ca: TRUSTED_CA_LIST
};

const client = mqtt.connect(options);

// In case of WebSockets connection, connect using host string including /mqtt path:
// const client = mqtt.connect('wss://mqtt.inteliglue.com:12345/mqtt', options);

const dataAccountRootName = 'yourdataAccountRootName'; // e.g. 1KD87RwQ4tDusX52dOREIG

client.on('connect', function() {
    console.log('Client connected.');
    client.subscribe(`${dataAccountRootName}/#`);
    client.publish(`${dataAccountRootName}`, 'Hello Inteliments');
    client.end(); // Close client connection.
});

client.on('message', function(topic, message) {
  console.log(message.toString());
});

client.on('error', function(err){
  console.log(err);
});