MQTT Plugin

The MQTT plugin allows sending the collected messages via MQTT and MQTT over websockets to a remote system. Proxy-support is on board as well as local message caching/persisting and data compression.

File location:

configs/configurations/OutputPlugins/MqttNet/MqttSettings.xml

Configuration

Mandatory settings

Two settings are mandatory for running the MQTT-plugin and connecting to the Senseforce MQTT broker. All the other settings are for advanced use-cases (see the section below).

The topic setting identifies the data sent to the Senseforce cloud and correlates them to a specific machine identifier. Renaming a machine identifier is not possible.

Sample configuration

A sample MQTT plugin configuration is illustrated below

<?xml version="1.0" encoding="utf-8" ?>
<MqttConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="https://senseforce.io/ ..\..\Schemas\mqttnetsettings.xsd" >
  <Broker>
    <Host>luna.senseforce.io</Host>
    <Port>8883</Port>
    <Secure>true</Secure>
    <AllowAnonymous>false</AllowAnonymous>
    <Username>username</Username>
    <Password>password</Password>
    <!-- Allowed settings for ProtocolVersion: NONE, Version_3_1_0, Version_3_1_1 (default), Version_5_0_0-->
    <ProtocolVersion>Version_3_1_1</ProtocolVersion>
    <!-- Allowed settings for TlsVersion: NONE, SSL3, TLS_1_0, TLS_1_1, TLS_1_2-->
    <TlsVersion>TLS_1_2</TlsVersion>
    <!-- by default tcp mqtt server is used. Set UseWebsockets to true, to enable communication via websockets-->
    <!-- Use the Host-setting above to give the fully qualified websocket address (like luna.senseforce.io:443/mqtt). The Port-setting is ignored for websockets.
         Define the port directly in the Host-entry.-->
    <UseWebsockets>false</UseWebsockets>
    <!--<Proxy>
      <Address>http://myproxy:23500</Address>
      <Domain></Domain> <!-- Proxy server domain -->
  		<Username></Username> <!-- Proxy server user name -->
  		<Password></Password> <!-- Proxy server password -->
    </Proxy>-->
  </Broker>
  <Compression>LZ4</Compression>
  <!--Currently implemented: LZ4, Disabled-->

  <!--Messages arriving from ingress plugins are batched until the NumberOfMessagesToCombine is reached or the MessageCombineCounterMs are elapsed. Then they are sent.-->
  <NumberOfMessagesToCombine>500</NumberOfMessagesToCombine>
  <MessageCombineCounterMs>5000</MessageCombineCounterMs>

  <Topic>tenant/test</Topic>

  <PersistMessagesOnFileSystem>true</PersistMessagesOnFileSystem>
  <PersistencePath>$(LunaAppDataPath)configurations/OutputPlugins/MqttNet/Persistence</PersistencePath>

  <!-- If EnableServerCertAuth is set to false, all server certificates are trusted-->
  <EnableServerCertAuth>true</EnableServerCertAuth>
  <CaFilePath>$(RuntimePath)data/certs/ca.pem</CaFilePath>

  <!-- Set to true, if the oldest message should be deleted in case of the MaxReconnectBuffer is hit. Otherwise, the newest incoming messages are removed -->
  <DropOldestIfOverflow>true</DropOldestIfOverflow>
  <MaxReconnectBuffer>100000</MaxReconnectBuffer>

  <!-- Maximum and minimum reconnect time. A random time interval between these two values is waited after a connection loss to wait for reconnect.-->
  <MinReconnectTimeSeconds>20</MinReconnectTimeSeconds>
  <MaxReconnectTimeSeconds>1200</MaxReconnectTimeSeconds>

  <Logger>
    <FilePath>$(LunaAppDataPath)Logs</FilePath>
    <FileName>mqttnet.log</FileName>
    <!--LogLevel: Debug,Information,Warning,Error,Critical,None-->
    <LogLevel>Information</LogLevel>
  </Logger>
</MqttConfiguration>

Advanced Settings

The following settings are available: (Note: the corresponding line in the above sample file is provided in brackets).

Sample file

Last updated