Product Documentation

MQTT V3 Plug-in Reference

Previous Topic

Next Topic

Configuring the MQTT Plug-in

These instructions assume you have downloaded FairCom Edge database and installed it on the same machine as the application. See Download and Installation. They also assume you have followed the directions elsewhere in this document to configure your environment.

Enabling the MQTT (Message Queuing Telemetry Transport) Plug-in

For security reasons, plug-ins are not enabled by default.

The MQTT plug-in is enabled by adding the following information to the server configuration in the file named ctsrvr.cfg in the server/config folder:

Windows:

PLUGIN cthttpd;./web/cthttpd.dll

Linux/Unix:

PLUGIN cthttpd;./web/libcthttpd.so

The plug-in is loaded at server startup and starts listening for MQTT messages and starts sending messages in response to previously cached data and new data collected by the database.

MQTT Plug-in Configuration

The MQTT plug-in is configured using the cthttpd.json file in the \server\config\ folder. This file is in JSON format. It contains all the HTTP configuration settings. The MQTT settings are controlled by the properties starting with mqtt_.


{

"listening_https_port": 8443,

"ssl_certificate": "./web/fccert.pem",

"document_root": "./web/apps",

"mqtt_enabled": true,

"mqtt_listening_port": 1883,

"mqtt_persistence_enabled": true,

"mqtt_log_enabled": false,

"mqtt_websocket_port": 8081,

"mqtt_websocket_ssl_enabled": true,

"mqtt_statistics_interval": 5,

"applications": [

"mqtt;ctMQTT.dll",

"ctree;ctREST.dll"

]

}

If you want to run the HTTP server but you do not want to run MQTT, set mqtt_enabled to false.

"mqtt_enabled": false

You can change the TCP/IP port on which MQTT is listening by setting "mqtt_listening_port" to another port number, such as 2020.

"mqtt_listening_port": 2020

If you want to use the FairCom Edge to broker MQTT messages but you do not want to cache data from those messages, set "mqtt_persistence_enabled" to false.

"mqtt_enabled": false

You can turn on MQTT logging by setting "mqtt_log_enabled" to true.

"mqtt_log_enabled": true

Definitions of additional MQTT configuration parameters:

  • "mqtt_websocket_port" - The port used for MQTT broker communication.
  • "mqtt_websocket_ssl_enabled" - Indicates if SSL communication should be used by the MQTT broker. true | false. Default is false.
  • "mqtt_statistics_interval" - Interval in seconds between the monitoring messages in our MQTT broker implementation. If 0, no messages will be posted. Default is 5 seconds.

Advanced SSL Certificate Options

The ssl_certificate keyword in the config/cthttpd.json web server plug-in configuration supports the fccert.pem, which is a self-signed certificate we supplied. To use your own certificate, use the following keywords to config/cthttpd.json:

  • ssl_key: SSL private key - This can be embedded in the same file provided the in ssl_certificate. For example, our default fccert.pem certificate file has both the certificate and the private key, so, ssl_key is not required.
  • ssl_ca: SSL Certificate Authority - External authority that issues and validates the certificate.
  • ssl_cipher_suites - Colon-delimited list of SSL cipher suites.

TOCIndex