MQTT Broker Tutorial – Build IoT Application better

Introduction

Bevywise MQTTRoute is a complete IoT Application Suite with an inbuilt MQTT Broker. It acts as a central MQTT server for MQTT messaging, that facilitate MQTT connections to collect data from edge devices / Internet of Things (IoT) devices, store them into any big data engines, and send data to the subscribing client.

MQTTRoute uses Message Queuing Telemetry Transport (MQTT) protocol as its standard messaging protocol / communication protocol. MQTT works based on the publish-subscribe model. It provides you a fully extendable framework which helps you build powerful IoT / IIoT Application for any industrial use cases.

MQTT Versions Supported :
  • MQTT 3.1
  • MQTT 3.1.1
MQTT Broker Packages :

MQTTRoute is available both as a premium edition & FREE edition.

To know more on the premium edition, check our broker pricing page.


FREE Edition

FREE edition, which is also known as a Developer edition, is a Fully FREE version making it available exclusively for Developers who are intended to build their own application using it.

This pack includes :

  • 10 device connections
  • No limitation in terms of features
  • FREE forever

Note : To connect more number of devices, upgrade to the premium version.

For Basic User

Here is everything a basic user can make use of from MQTT Broker installation, device connection to device management. Feel free to reach support for any queries.

MQTT Broker Installation and Running

Download FREE version:

MQTTRoute is available to download on Windows / Windows servers ( 64 bit), and Linux. The binaries are available as a zip archive for Linux and as a self-extracting exe for the Windows OS.

You can get your FREE MQTT Broker package from our Broker download page.


System Requirements (for FREE version):
  • Processor – 1 GHZ or higher
  • Memory – 512 MB or higher
  • Hard Disk – 50 GB or higher
Steps to start the MQTT Broker

Start MQTTRoute in Windows:

You can start MQTT Broker in multiple ways in windows :

  • Double click the “runbroker.bat” file inside the Bevywise/MQTTRoute/bin folder. (or)
  • Open cmd as administrator and go to Bevywise/MQTTRoute/bin folder.
  • Next, type “runbroker.bat” and hit enter.
cd ./Bevywise/MQTTRoute/bin
runbroker.bat
To start MQTTRoute in Other operating systems:

Open terminal window. Go to the path where the downloaded MQTT Broker package is located & unzip the archive.

cd unzip Bevywise_MQTT_Route.zip
  • Open bin folder in the unzipped package. Typical location can be .Downloads/Bevywise/MQTTRoute/bin.
  • Now run sh runbroker.sh
cd ./Downloads/Bevywise/MQTTRoute/bin
sh runbroker.sh

By default, broker starts on localhost IP address (127.0.0.1) and listens on port 1883.

Note : Check UI configuration part if broker failed due to socket error.

Other ways to start MQTT Broker

The other method through which you can start the message broker is by running it as a service. Running broker as a service helps you start broker automatically when the machine starts. You can avoid running it every time from the terminal or command prompt.

We have added this support for Windows & Linux.


For Windows

To start MQTTRoute service,

  • Open command prompt in administrator mode. Go to ./Bevywise/MQTTRoute/bin and run CreateMQTTRouteSvc.bat. This will create the MQTTRoute service and start the same.
cd ./Bevywise/MQTTRoute/bin
CreateMQTTRouteSvc.bat

To stop MQTTRoute service,

  • Open command prompt in administrator mode. Go to ./Bevywise/MQTTRoute/bin and run RemoveMQTTRouteSvc.bat. This will stop the broker and remove it from services.
cd ./Bevywise/MQTTRoute/bin
RemoveMQTTRouteSvc.bat
For Linux

The bin folder (Bevywise/MQTTRoute/bin) contains RunAsService.sh file. Run this file to enable ‘set up the service file’ and ‘path’ (set as a symbolic link redirect to “/opt/Bevywise” folder).

cd ./Bevywise/MQTTRoute/bin
sh RunAsService.sh

Now, to start a service, use

sudo systemctl start mqttroute.service

To check status, use

sudo systemctl status mqttroute.service

To stop service, use

sudo systemctl stop mqttroute.service

MQTTRoute User Interface

By default, the UI of the broker starts running in the port 8080.

You can access it by navigating to the browser and entering http://localhost:8080

Note : Check UI configuration part if you need to change the UI port

Connecting clients / devices

Once your installation & setup is completed, you can start connecting your devices, collect data & monitor it. If you don’t have one, you can download it from our python client libraries for different OS.

The below steps provides the procedure to connect MQTT Broker with above mentioned python client.

Pre-Requisites

Make sure you have the python installed in your system.

Minimal requirement – Python 2.7

Unzip the downloaded python client library.

You can find the file named MQTTClient.py on accessing the client library.

Open the file in any editor and we have to do some configurations in the file to make it connect with our MQTT Broker

#Getting Connection Information
SERVER_NAME = “localhost”
SERVER_PORT = int(1883)

SERVER_NAME is the field where the IP address / DNS hostname of the broker should be given.

Note : The above instructions assumes that MQTT Broker is running in local machine and hence it is given as ‘localhost’. If MQTT Broker is running in any other server, IP address / hostname for the same should be provided.

SERVER_PORT – The port at which the MQTT broker is running. By default the broker starts at port 1883. If the broker uses TLS / SSL enabled authentication, then you can change the port to 8883.

Check Advanced Authentication (TLS / SSL) for more information.

#Getting MQTT Credential Informations
MQUsername = “**********”
MQPassword = “**********”

The next step is to enter your Authentication credentials. You can get these credentials from MQTT Broker.

If you have disabled your Authentication field in MQTT Broker, you can leave this space unfilled & proceed.

Check Authentication Tab to know more.

#Getting MQTT Credential Informations
MQUsername = ” ”
MQPassword = ” ”

The final step is to fill in the following parameters as required

MQClientID = “Client01”
Publish_Topic_Name = “Client01/Status”
Publish_Message = “Active”
Subscribe_Topic_Name = “Client01/Status”

MQClientID – This is the custom identifier field where you can provide specific ID to your client.

Publish_Topic_Name – The topic at which your client will send messages. You can fill in any custom topic names with multiple topic levels.

Click to know more on MQTT Topic.

MQTT supports 'Persistent session' feature, with the help of which broker can keep track of the client's information as well as the topics to which it is subscribed.

Publish_Message – You can decide what message / data needs to be published.

Subscribe_Topic_Name – The specific topic which your client will subscribe to.

In addition, you can change QoS, Retain or other parameters if needed.

Click to know more on QoS & Retain .

Now the configurations are set and the client is ready to get connected to the MQTT Broker.

To do so, open command prompt / terminal and go to the repository in which the MQTT Client library is located.

cd ./Downloads/MQTTClient

Then, start running the client by giving the following command.

python MQTTClient.py

Note : The name of my client file is MQTTClient.py. You can replace this with your file name.

Then the verification print will be displayed in terminal with all the configurations you have made in the client file. You can cross-check the details & press enter.

If the configurations are done right, client will get connected to the broker.

You can check the flow of messages both in the terminal and in the MQTT Broker Dashboard.

Check Dashboard tab to know more.


Device level Security & Authentication

MQTT authentication enables you to connect your devices more securely with authentication credentials. (See Connecting MQTT Clients / Devices).

This requires you to enable Authentication field in broker.conf file present in conf folder.

  • Go to ./MQTTRoute/conf (Path may vary)
  • Open broker.conf
  • You can find AUTHENTICATION_ENABLED field is set to NO. You can change it to YES.
broker.conf

[AUTHENTICATION]
AUTHENTICATION_ENABLED = YES
# YES || NO

Save the file & restart the broker.

Now go to the UI of MQTT Broker. You will find the ‘Security’ tab displayed. You can get your Authentication credentials for secure device connection.

  • Username – Auth key
  • Password – Auth token

You can either use the default authentication parameters present in the security tab or you can create a new one.

To create Authentication parameters :

  • Go to security tab & Click the + icon on the top right corner.
  • Enter your preferred ‘Auth key’ & ‘Auth Token’ and click save.
To delete Authentication :

Click 'x' icon next to the added auth key and auth token to delete authentication credentials. The devices with the deleted credentials can no longer connect to the MQTT Broker.

UI Configuration
To change UI port

Go to broker.conf present inside Conf folder.

By default, UI will be running in port 8080. You can change the port here based on your need.

User Interface Configuration [UI] UI_Http_Port =8080

UI port change may be required in scenario when port 8080 is occupied by some other application running on your system. If you are not aware of some other application running, you will get [Error 98] while running MQTT Broker.

Check the screenshot below for details.

terminal

In such a scenario, you can change the UI to some other port (make sure no other application is running).

Enable / Disable Web login

Web login can be enabled or disabled based on the need. By default, MQTT Broker UI login will be enabled. You can disable the web login in broker.conf file.

[WEB_LOGIN_PAGE]
WEB_LOGIN = ENABLED
# ENABLED || DISABLED
Change Password
From UI

By default, you can access the dashboard by providing username & password as admin & admin. If you would like to change the password, you can do it directly from the UI.

  • Login with default credentials.
  • Click on setting icon present at the top right corner of the dashboard.
  • Then click change password.
  • Provide current password & new password (password to be changed) in the respective space given.
  • Click save and your password will be changed now.
Detailed View of UI

The well executed MQTT Broker UI enables you to monitor, visualize & manage your connected devices & data. You can drill down deeper to make optimum use of the user interface.

Dashboard

The dashboard provides a quick snapshot of the latest happenings in the Broker, where you can view the real time data coming from your devices. Along with raw data, you can expect the quick real time status of the broker.


  • Active Devices – Devices that are currently active
  • Total Devices – Total number of devices connected so far to the broker
  • Events – Total number of messages / data published
  • Commands – Total number of messages / data received
  • Recent Events – The real-time view of recent data published.
  • Recent Device Log – The recent view on error occurred while connecting devices.
  • Recent Connections – The recent list of devices connected
  • Recent Disconnections – The recent list of devices disconnected
dashboard

In addition to the default dashboard, MQTT Broker supports custom one which allows users to create multiple dashboards specific to their applications. Let us dig deeper to know how it can help for your application.

Custom Dashboard

The usage of dashboard varies with the use-case & application and it is not fair to provide static dashboard for all IoT implementations. Hence, MQTTRoute supports creating custom dashboard with set of pre-built widgets to help users have better visualization specific to their application or industrial needs.

Unlike other MQTT Broker/servers you don’t need any third party plugin to visualize your data. You can create multiple dashboards with this functionality from the UI itself. As of now, MQTTRoute supports 9 pre-built widgets. Just lay out the widgets on the dashboard and provide a value-bringing visualization to your data.

List of widgets supported

  • Text
  • Color
  • Line Chart
  • Bar Chart
  • Gauge Chart
  • Vertical Gauge
  • Horizontal Gauge
  • LED Light
  • Switch
How to create Custom Dashboard?
To create a Custom dashboard :
  • Click “Create Dashboard” at the menu bar.
  • The Model Title window will appear showing, “Dashboard name” and “Description”.
  • Enter “Dashboard name” and a small “Description” in the respective box provided.
create dashboard
  • After completing, click the “Create” button to open the “Widgets” tab.
  • Then click the "+" icon at the top right corner of the widgets tab. ‘Create Widget’ window will appear along with the drop-down menu which lists the types of widgets.
custom dashboard create widget
To create a Widget :

Widgets support JSON data and TEXT. Make sure you create widget only for numerical data.

The steps to make 9 different types of widgets are listed below.

Text Widget :
  • Select the ‘Text widget’ if you wish to display data in the form of plain text. This helps you highlight the values of specific parameters in a data.
  • Now provide a title and select device from the device list.
  • The drop down menu will list all the clients (both active and inactive) connected to the platform.
  • Select the device which is active (your preferred device) from the list to view data flow in real-time.
  • Now you have to enter a topic for which your selected device is associated with.
  • If you have multiple topics for a particular device, all the topics will be listed in the drop-down menu.

Click to know more on MQTT Topics.

  • Then you have to select a key. Key refers to the parameters your JSON data has.

(For example – JSON syntax will be like

{ “ KEY 1” : “ VALUE1 ” , “KEY2” : “ VALUE2 “ , “ KEY 3“ : “VALUE 3” }

Example for JSON data

{ “sensor” :”99″ , “temperature” : “90” , “status” : on” }

In the above data, sensor, temperature, status are referred to as keys and 99, 90 and ON are values for the keys.

For instance, if I want to display temperature data, I have to select the key as “temperature”. Then I have to enter unit for the data. As I have selected temperature as the key, I have given Celsius as unit. You can enter the right unit based on your data.

  • The color selection will allow you to select the color for the entire widget.
  • Then Minimum and Maximum refer to the range of your data. If I know that my data will reside in the range 0 to 100 or 40 to 80 etc., I can mention here.
  • Finally offset, it is an optional column. The effect of this parameter will vary based on the widget.
  • For example, in case of Text widget, if temperature is normal or low, I need to display that as a GREEN colored text. Similarly if it is very high, I need to display that as RED colored text showing a Alert!! This is how offset helps in text widget. So I can enter the low temperature value as offset in the first column and will give green color for it. And then in the next column, I will enter the high temperature as offset and will give RED color.
  • Now, the inputs are given and you can view the text widget on submit.

text widget
Color Widget :

Color widget helps you view data in a coloured form. Also, you can set different colors for each optimum range of values.

The steps are the same as those of creating a TEXT widget.

  • After providing the device details, topic & key selection & minimum & maximum range, you can proceed entering the offset values.
  • The usage of offset will vary here as you can make your desired MESSAGE to be displayed with selected background color.
  • For example, my device is publishing the speed data and speed range is between 0 to 200. I want to get instant alert based on speed in three different formats like Normal, Medium & High speed in dashboard in coloured format.

Let 0 to 50 be normal speed, 50 to 100 be medium speed and more than 100 be High speed. Now check the steps below.

  • Enter the first offset value as 50 and enter the subtitle as ‘Normal’ (as I want to display the text in a widget). Then you can select the preferred color (Background) to be displayed.
  • Enter the second offset value as 100 and enter the subtitle as ‘Medium’ (as I want to display the text in a widget). Then you can select the preferred color (Background) to be displayed.
  • Enter the third offset value as 100 and enter the subtitle as ‘Speed Alert’ (as I want to display the text in a widget). Then you can select the preferred color (Background) to be displayed.
  • Now you will be alerted with the speed in your preferred color
colour widget

Line Widget :

Line Widget allows you to create trend that is to view data that changes over time. This helps you create a series of values connected with a straight line. You can also compare changes over the same period for more than one value.

The steps are the same as those of creating a TEXT & Color widget. But there won’t be any option to set minimum and maximum range & offset as this is a trend chart.

  • Select Line chart from the widgets list.
  • Choose which kind of data you prefer : Live or Historical
  • Then, provide a title and select device from the device list.
  • The drop down menu will list all the clients (both active and inactive) connected to the platform.
  • Select the device which is active (your preferred device) from the list to view data flow in real-time.
  • Now you have to enter a topic for which your selected device is associated with.
  • If you have multiple topics for a particular device, all the topics will be listed in the drop-down menu.
  • Then you have to select a key and provide a suitable sub-title & unit for the key.

As it is a trend chart, it displays data over time. Hence it is a chart of your data vs time. Data (value) will occupy y-axis and time will occupy x-axis. The subtitle & unit you provide will be displayed in y-axis.

  • Now you can provide your preferred color for the line which connects your data.
  • Click submit and your line chart will be created.

Note : When chosen Historical data, you can export the data for your preferable period of days.

line widget

To compare two or more values

Comparing two or more values (data) of a single device can be done with line widget.

Follow the steps below to create data comparison chart.

  • Use necessary steps in creating line widget as mentioned.
  • Before submitting the details, click + icon near color selection bar of first key.
  • Now proceed further by entering another key in a data, subtitle, unit and color.
  • You can add more keys based on how many keys the data of selected device has.
  • Now click submit and you can view the data comparison chart.
Bar Widget :

The usage of Bar widget is the same as that of line widget and it represents data in rectangular bars with heights proportional to the values they represent.

  • Select Bar chart from the widgets list.
  • Choose which kind of data you prefer to get : Live or Historical
  • Then, provide a title and select device from the device list.
  • The drop down menu will list all the clients (both active and inactive) connected to the platform.
  • Select the device which is active (your preferred device) from the list to view data flow in real time.
  • Now you have to enter a topic for which your selected device is associated with.
  • If you have multiple topics for a particular device, all the topics will be listed in the drop-down menu.
  • Then you have to select a key and provide a suitable sub-title & unit for the key.

As it is a trend chart, it displays data over time. Hence it is a chart of your data vs time, data (value) will occupy y-axis and time will occupy x-axis. The subtitle & unit you provide will be displayed in y-axis.

  • Now you can provide your preferred color for the bar which represents the key.
  • Click submit and your Bar chart will be created.

Note : When chosen Historical data, you can export data for your preferable period of days.

bar widget
To compare two or more values

Comparing two or more values (data) of a single device can be done with bar widget.

Follow the steps below to create data comparison chart.

  • Use necessary steps in creating bar widget as mentioned.
  • Before submitting the details, click + icon near the color selection bar of first key.
  • Now proceed further by entering another key in a data, subtitle, unit and color.
  • You can add more keys based on how many keys the data of selected device has.
  • Now click submit and you can view the data comparison chart.
Gauge Widget :

Gauge chart which visually illustrates a speedometer is used to represent progressive values.

The steps are the same as that of TEXT & COLOR widget.

  • After providing the device details, topic & key selection & minimum & maximum range, you can proceed entering the offset values.
  • The minimum & maximum value here depicts the starting and ending point in a dial.
  • The usage of offset will vary here as each offset represents the data range in a dial which is finally pointed by a needle. You can select different colours for different offsets.

Let us consider a pressure gauge and the data on pressure falls between the range 0 to 100. Now I can divide the dial into 5 different ranges.

  • 0 to 20
  • 20 to 40
  • 40 to 60
  • 60 to 80
  • 80 to 100

Each category represents each offset and I will assign different colors for the same. The needle will hove over & point out the pressure value based on the data received in dial.

gauge widget

Vertical Gauge & Horizontal Gauge :

The usage of Vertical & Horizontal gauge is the same as that of Gauge but used to represent linear progressive values.

The steps for widget creation are exactly the same but you will have the linear scale (horizontal or vertical) instead of dial. You can set the offset based on this.

For step by step procedure, please check Gauge widget

vertical gauge horizontal gauge
LED Widget :

It is a condition based widget which works for random data. It can be used in a scenario of checking the status of the device either active or inactive.

Follow the steps below to create LED widget.

  • Select LED from the widgets list.
  • Choose which kind of data you want : Live or Historical
  • Then, provide a title and select device from the device list.
  • The drop down menu will list all the clients (both active and inactive) connected to the platform.
  • Select the device which is active (your preferred device) from the list to view data flow in real time.
  • Now you have to enter a topic for which your selected device is associated with.
  • If you have multiple topics for a particular device, all the topics will be listed in the drop-down menu.
  • Then you have to select a key.

Note : When chosen Historical data, you can export data for your preferable period of days.

Note : LED works only for the device which sends data in RANDOM. For example, On|Off or Open|Close

Now provide the value (ON) you receive when your device is active and (OFF) when device is inactive in the respective space given. Choose your desired color. Based on the color chosen, LED will blink representing the device status.

LED widget
Switch Widget :

This is a user interactive widget where you can control the activity of device from the UI itself.

You can choose which kind of data you wish to get : Live or Historical

Based on the topic / event received by device, you can make your device ON / OFF or the action you need to perform with the subscribed data.

You can manually ON/OFF the device with the switch widget.

Note : When chosen Historical data, you can export data for your preferable period of days.

Note : Make sure the device you want to control is subscribed to the topic that has random data (ON / OFF or Open / Close).

switch widget
Devices Tab :

This tab displays complete the list of devices (both active & inactive) that are connected to the MQTT Broker. Devices tab provides you a high level view on each device connected.

Let us dig deeper to know how the ‘Devices’ tab can help.

Dashboard can provide the latest quick events of devices. But how can we get the complete list of events published? and the commands received if it is a subscriber.

How can I send an instant command to the devices?

All these questions can be answered if you can make the optimum use of ‘Devices’ tab.

  • Go to ‘Devices’ tab
  • Click anyone from the devices listed.
devices tab
Events :

The complete list of events published by the device selected.

You can also get,

The list of messages published along with its associated topics by the selected device.

events
Commands :

The complete list of commands subscribed by the device selected.

You can also get,

  • The list of messages received along with its associated topics by the selected device.
  • QoS level of each topic subscribed.
  • The time at which the message received.
commands
Subscribe Topics :

This is nothing but the list of topics subscribed by the particular device.

subscribe topics
Send Command :

‘Send Command’ helps you to send instant messages to other devices.

Follow the steps to send an instant command :

  • Select topic name from the drop down menu.
  • Make sure the topic is subscribed by the device to which you are sending command.
  • Enter the command to be sent in the message tab.
send command
Topics :

The absolute list of topics published and subscribed by all devices connected to the broker.

publish topics active subscriptions
Rules Engine

The Rules are the first step to build intelligence to the broker. It is an automation engine where you can create alert based on the message received .

The rule engine comprises of Condition-based & Time based rules.

Condition based rule creation :
  • Client & Topic – Rule creation based on Client & topic
  • Topic & Message – Based on Topic & Message
  • Client & Topic & Message – Based on Client name, topic & message
rules
Client & Topic :

This rule type enables you to create rules based on client & the topic it is associated with.

Let us consider the scenario. My publisher is publishing the data with the topic, pub/test in 2 minutes interval. And I want my subscriber with the topic sub/test subscribed to know that publisher is publishing the data or not.

So, I can create a rule that whenever the Publisher sends data, the subscriber will receive the message ‘Message Sent’.

Note : This is just an example scenario, you can create your own rule based on your need.


Steps to create Client & Topic rule type :
  • Go to Rules tab & click + icon present at the top right corner.
  • The dialog box will be displayed to generate rule.
  • Now Select ‘Client & Topic’ in Rule type.
  • Provide the client ID of your publisher & Topic which the publisher is associated with.

If it has multiple topics, select the topic for which you are intended to generate a rule.

Now enter the topic which is about to receive the random message (yet to configure in rules)

Note : Device whichever is subscribed to this topic will receive the message configured.

Enter the message to be sent & click submit.

Alternatively, if you would like to send the message as it is from the publisher, click ‘forward’. This will forward the messages published as it are to the subscriber.

create rule
Topic & Message :

This rule type enables you to send a response based on the message received and it is associated only with the topic & not with the device. (i.e) You can create rule specific to any publishing topic & it is not limited to the device associated with.

This rule type will be helpful for the below mentioned scenario.

Let us consider my temperature sensor is publishing the temperature data in a range 0 to 50 and if it reaches the optimum value of 50, I have to send an alert message to the subscriber. So with topic & message rule type, I can set the condition that, if the data received is = 50, then send an alert message ‘Temperature High’.

Note : This is just an example scenario, you can create your own rule based on your need.

  • Go to Rules tab & click + icon present at the top right corner.
  • The dialog box will be displayed to generate rule.
  • Now Select ‘Topic & Message’ in Rule type.
  • Provide Topic your preferred publishing topic.
  • Select the condition (=, <,>) and enter the value. (If the condition is = 50 then, you can select the condition as = and enter the value as 50).

Now enter the topic which is about to receive the random message (yet to configure in rules)

Note : Device whichever is subscribed to this topic will receive the message configured when the condition set is satisfied.

Enter the message to be sent & click submit.

Alternatively, If you would like to send the message as it is from the publisher, click ‘forward’. This will forward the messages published as it are to the subscriber on satisfying the condition set.

topic message rule
Client-Topic-Message :

This rule type enables you to send a response based on the message received and it is associated with both topic & message (i.e) You can create rule specific to any publishing topic that is associated with the particular device.

The steps are the same as those of Client-Topic-Message rule type.

  • Go to Rules tab & click + icon present at the top right corner.
  • The dialog box will be displayed to generate rule.
  • Now Select ‘Client-Topic-Message’ in Rule type.
  • Provide the client ID of your publisher & Topic which the publisher is associated with. ( If it has multiple topics, select the topic for which you are intended to generate a rule.)
  • Select the condition (=, <,>) and enter the value. (If the condition is > 40 then, you can select the condition as > and enter the value as 40)
  • Now enter the topic which is about to receive the random message (yet to configure in rules)

Note : Device whichever is subscribed to this topic will receive the message configured when the condition set is satisfied.

Enter the message to be sent & click submit.

Alternatively, if you would like to send the message as it is from the publisher, click ‘forward’. This will forward the messages published as it are to the subscriber on satisfying the condition set.

client topic message
Timer based Rule creation :

Timer Rule – Rule creation based on the given date and time.

Timer rule helps in scheduling the rule to execute it in a preferred date & time. (i.e) You can send an alert for the specified date & time.


  • Select ‘Timer’ in rule type.
  • Provide the client ID of the publisher.
  • TThen enter the topic, which is subscribed by the above specified device, to which you are about to send the alert.
  • Enter the message to be sent.
  • Then the alert can be scheduled for
  • Specific date
  • Date range
  • Day of the week
  • Select your preferred one and click create.

Once done, the alert will be received by the subscriber client for the mentioned date & time.

timer rule
Device Log :

The connection of device with the broker may be restricted / interrupted due to so many reasons. The Device Log tab contains a list of errors occurred while connecting a device to the broker. This helps you know the reason behind the failure.

device log


The below list helps you to identify the reason for the error.


ERROR REASON
Server busy Server busy, number of socket connection exceeded Server physical limit reached
Unknown Client Client details are not given properly. Invalid Client details provided
Client id Null Client id Null, Connection entry restricted Client Identifier is NULL
Connection Refused Same client id already found, try to connect with another client id Reusing an existing Client Identifier not allowed
Invalid Credential Username or password wrong. Connect with the correct user credential. Invalid Authentication Details Provided
Ping Response Failed Device went offline. TCP Timeout occurred.
SSL Accept Error while establishing a secure connection. Invalid SSL Certificate or Connection
Protocol Not Supported Invalid Protocol. The Received message is not in proper MQTT Format
Socket Closed Server is busy
Device Disconnected Unexpectedly device disconnected
For Advanced User :

Here is everything a developer can make use of MQTTRoute for advanced configurations & implementation

The complete details on MQTT Broker Installation, basic features and configurations are available in ‘FOR BASIC USER’ Tab.


For advanced configurations & integrations, you can check here.

SSL / TLS Configuration
Connecting devices via TLS / SSL

The Broker can be run in TLS mode, there by making the communication more secure.

To enable TLS, follow the steps below

  • Go to ./MQTTRoute/conf (Path may vary)
  • Open broker.conf
  • You can find TLS_ENABLED = FALSE. You can change it to TRUE.
TLS_ENABLED = TRUE
# TLS_PORT must be 88xx
TLS_PORT_NO = 8883
WSS_PORT_NO = 11443

As TLS is enabled, broker will start running in the port 8883 instead of 1883.

Note : WSS_PORT_NO is to start the MQTT SSL version in Websocket

By default, MQTTRoute comes with Self-Signed Certificates whose paths are set in broker.conf. If any other Certificates are used, these paths must be set accordingly.

You can find the certificate inside Certificate folder ../MQTTRoute/Certificate.

You can find the details about the certificates provided here.

SERVER_CERTIFICATE = ./../Certificate/server/server.crt
SERVER_KEY = ./../Certificate/server/server.key
CA_CERTIFICATE = ./../Certificate/root/root.crt

You can upload these certificates (Server or Root certificate) to your device or client side.

If you need to create your own self-signed certificate, check below.


How to generate & use Self-signed certificates with MQTTRoute (In Linux) ?
Create CA Certificate
$ openssl genrsa -out root.key 2048
$ openssl req -new -x509 -key root.key -out root.out

This will ask for the following details.

Country Name (2 letter code) [AU]:.
State or Province Name (full name) [Some-State]:.
Locality Name (eg, city) []:.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Bevywise
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:root CA
Email Address []:[email protected]

You can modify the details based on your need.

Create Server Key pair

$ openssl genrsa -out server.key 2048
$ openssl req -new -out server.csr -key server.key

Country Name (2 letter code) [AU]:.
State or Province Name (full name) [Some-State]:.
Locality Name (eg, city) []:.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Bevywise
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:root CA
Email Address []:[email protected]

Please enter the following ‘extra’ attributes to be sent with your certificate request.

A Challenge Password []:
An Optional Company Name []:

Note: These details can be modified. Ensure that the details filled in for root and server are not exactly the same.

$ openssl x509 -req -in server.csr -CA root.crt
-CAkey root.key – CAcreateserial -out server.crt

Upload the created certificates in the respective folders.

root.crt in ../MQTTRoute/Certificate/root
server.crt in ../MQTTRoute/Certificate/server
server.crt in ../MQTTRoute/Certificate/server

Finally, make sure you’ve enabled TLS in broker.conf.
Check Connecting Devices via TLS / SSL Tab for detailed steps

How to Generate & use Trusted CA Certificate with MQTTRoute ?

In this example, we will use certbot to generate LetsEncrypt Certificate and use that certificate to enable a secure TLS communication between MQTTRoute and its clients.

Install certbot:

$ sudo snap install -classic certbot

$ sudo ln -s/snap/bin/certbot/usr/bin/certbot/

Create Certificate :

$ sudo certbot certonly -standalone -d <your_domain>

The certificates will be created and saved in /etc/letsencrypt/live/ <your_domain >

Set the paths of these generated certificates in Bevywise/MQTTRoute/conf/broker.conf

TLS_ENABLED = TRUE
SERVER_CERTIFICATE = /etc/letsencrypt/live/<your_domain>/fullchain.pem
SERVER_KEY = /etc/letsencrypt/live/<your_domain>/privkey.pem
CA_CERTIFICATE = /etc/letsencrypt/live/<your_domain>/chain.pem
How to generate & use Self-signed certificates with MQTTRoute (In Windows)?
  • Create CA certificate
  • Open Windows File Explorer.
  • Navigate to the OpenSSL bin directory.
  • Right-click the openssl.exe file and select Run as administrator.
  • Enter the following command to begin generating a certificate and private key:

req -new -x509 -sha256 -nodes -days365 -newkey rsa:2048 -keyout
root.key -out root.crt


You will then be prompted to enter applicable Distinguished Name (DN) information, totalling seven fields :

Country Name (2 letter code) [AU]:.
State or Province Name (full name) [Some-State]:.
Locality Name (eg, city) []:.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Bevywise
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:root CA
Email Address []:[email protected]

You can modify the details based on your need.


  • Once completed, you will find the root.crt and root.key files created under the ..\\OpenSSL\\bin\\ directory

  • Create server key pair

    Again, navigate to the bin folder of openssl and enter the following commands:

    genrsa -out server.key2048

    req -new -out server.csr -key server.key

    You will then be prompted to enter applicable Distinguished Name (DN) information, totalling seven fields :

    Country Name (2 letter code) [AU]:.
    State or Province Name (full name) [Some-State]:.
    Locality Name (eg, city) []:.
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:Bevywise
    Organizational Unit Name (eg, section) []:MQTT Broker
    Common Name (e.g. server FQDN or YOUR name) []:server
    Email Address []:[email protected]

    Please enter the following ‘extra’ attributes to be sent with your certificate request.

    A Challenge Password []:
    An Optional Company Name []:

    Note: These details can be modified. Ensure that the details filled in for root and server are not exactly the same.

    Enter the following command in the prompt

    x509 -req -in server.csr -CA root.crt -CAkey root.key
    -CACreateserial -out server.crt

    Upload the created certificates in the respective folders.

    root.crt in ../MQTTRoute/Certificate/root
    server.crt in ../MQTTRoute/Certificate/server
    server.crt in ../MQTTRoute/Certificate/server

    Finally, make sure you’ve enabled TLS in broker.conf.

    Check Connecting Devices via TLS / SSL Tab for steps

    How to Generate & use Trusted CA Certificate with MQTTRoute (In Windows)?

    In this example, we will use certbot to generate LetsEncrypt Certificate and use that certificate to enable a secure TLS communication between MQTTRoute and its clients.

    Install certbot:

    Download the latest version of the Certbot installer for Windows from the url, https://dl.eff.org/certbot-beta-installer-win_amd64.exe.

    Create Certificate :

    Open the Windows Start Menu and launch Windows PowerShell as an Administrator.

    Enter the following commands to request a free Let’s Encrypt SSL certificate.

    PS> certbot -d <your_domain>

    The certificates will be created and saved in live folder of installation directory.

    Set the paths of these generated certificates in Bevywise/MQTTRoute/conf/broker.conf

    TLS_ENABLED = TRUE
    SERVER_CERTIFICATE = /etc/letsencrypt/live/<your_domain>/fullchain.pem
    SERVER_KEY = /etc/letsencrypt/live/<your_domain>/privkey.pem
    CA_CERTIFICATE = /etc/letsencrypt/live/<your_domain>/chain.pem
    Database Configuration

    The options to configure how data is stored by the Broker is set in Bevywise/MQTTRoute/conf/data_store.conf

    Device Information (Device IDs and Subscriptions) and MQTT Payload (Published/Received messages) are stored by the broker in one of the relational databases, by default. The relational databases supported by the Broker are: SQLite, MySQL, MSSQL and PostgreSQL. The UI uses this database.

    However, if the data needs to be stored in some other database, outside the Broker, then it can be configured too.

    Enabling / Disabling Storage in Relational Database

    To store both Device Information (Device IDs, Subscriptions) and Payload (Published/Received messages) in database,

    • Go to Bevywise/MQTTRoute/conf/data_store.conf
    • Set, RELATIONAL_PERSISTENCE_ENABLED as True and enable PAYLOAD_TO_DB
    RELATIONAL_PERSISTENCE_ENABLED = TRUE
    PAYLOAD_TO_DB = ENABLED

    If you don’t want to store both Device Information and Payload in database, then set

    RELATIONAL_PERSISTENCE_ENABLED = FALSE

    In this case, MQTTRoute UI is NOT available. Hence, PAYLOAD_TO_DB is assumed to be DISABLED.

    To store only the Device Information in database and NOT the MQTT Payloads, set

    RELATIONAL_PERSISTENCE_ENABLED = TRUE
    PAYLOAD_TO_DB = DISABLED

    In this case, only device information can be seen in the UI.

    Let us see the Relational Database Configurations below.

    Configuring SQLITE for MQTTROUTE

    SQLITE is the default storage option in MQTTRoute. And by default, Broker will store data in SQLITE.

    You can check the configurations set in data_store.conf. DB_SERVER will be set in SQLITE.

    [CONFIG]
    DB_SERVER = SQLITE
    # SQLITE || MYSQL || POSTGRES || MSSQL

    Also, check SQLite Server information. A sample configuration is given below:

    [SQLITE]
    SQLITE_DB = bevywise

    SQLite database will be stored in path Source/Bevywise/MQTTRoute/data

    Configuring MySQL for MQTTRoute

    To configure MySQL Server as the relational database used by MQTTRoute, set in Bevywise/MQTTRoute/conf/data_store.conf

    DB_SERVER = MYSQL

    Also, set MySQL Server information. A sample configuration is given below.

    [MYSQL]
    DBHOST = 127.0.0.1
    DBPORT = 3306
    MYSQL_DB = bevywise
    MYSQL_USER = root
    MYSQL_PASSWORD = root

    Note : The server configuration needs to be get from your MySQL server.

    To install MySQL, please refer the MySQL installation tab.

    Configuring MSSQL for MQTTRoute

    To configure MSSQL Server as the relational database used by MQTTRoute, set in Bevywise/MQTTRoute/conf/data_store.conf

    DB_SERVER = MSSQL

    Also, set MSSQL Server information. A sample configuration is given below

    [MSSQL]
    DRIVER = ODBC Driver 17 for SQL Server
    SERVER_NAME = /
    DBPORT = 1433
    MSSQL_DB = bevywise
    MSSQL_USER = SA
    MSSQL_PASSWORD =

    In Linux, set SERVER_NAME as the value of ‘Description’ in file: /etc/odbcinst.ini

    Configuring PostgreSQL for MQTTRoute

    To configure PostgreSQL Server as the relational database used by MQTTRoute, set in Bevywise/MQTTRoute/conf/data_store.conf

    DB_SERVER = POSTGRES

    Also, set PostgreSQL Server information. A sample configuration is given below

    [POSTGRES]
    PSQLHOST = 127.0.0.1
    PSQLPORT = 5432
    PSQL_DB = bevywise
    PSQL_USER = postgres
    PSQL_PASSWORD = admin
    Configuring Elasticsearch to store MQTT Payload data

    To configure MQTTRoute to store only MQTT Payload in Elasticsearch, set in Bevywise/MQTTRoute/conf/data_store.conf

    [DATASTORE]
    CUSTOMSTORAGE = ENABLED
    DATASTORE = ELASTIC
    [ELASTIC]
    HOSTNAME = 127.0.0.1
    PORT = 9200
    INDEX_NAME = mqtt
    BULK_INSERT_TIMING = 2

    Elasticsearch configuration must be set as required.

    In case, along with the requirement to store Payload in Elasticsearch, complete UI is also required, then set

    RELATIONAL_PERSISTENCE_ENABLED = TRUE
    PAYLOAD_TO_DB = ENABLED

    If PAYLOAD_TO_DB = DISABLED, then Payload will be stored only in Elasticsearch.

    A sample format of payload data stored in Elasticsearch is as follows

    {
    “_index”: “mqtt”,
    “_type”: “_doc”,
    “_id”: “HtXFGYUBFn1GomWaBxtF”,
    “_version”: 1,
    “_score”: 1,
    “_source”: {
        “topic”: “t2”,
          “unixtime”: 1671174619,
          “message”: {
            “temp”: 1,
              “pressure”: 30,
              “status”: 1
          },
        “sender”: “tc1”,
        “timestamp”: “2022-12-16T12:40:19”
        }
      }
    Configuring MQTTRoute to store MQTT Payload data in a custom database

    To configure MQTTRoute to store only MQTT Payload in any external database in a custom format, set in Bevywise/MQTTRoute/conf/data_store.conf

    [DATASTORE]
    CUSTOMSTORAGE = ENABLED
    DATASTORE = CUSTOM
    [CUSTOM]
    INTERCEPT_FILEPATH = ./../extensions/custom_store.py

    In this case, the MQTT Payload received from devices are available at a method handle_Received_Payload(data) and MQTT Payload sent to devices are available at a method handle_Sent_Payload(data).

    These two methods must be defined in a Python file whose path must be set in INTERCEPT_FILEPATH.

    How to store MQTT Payload data in Redis Server?

    Refer this Github page for MQTT Route Redis Connector.

    How to store MQTT Payload data in MongoDB?

    Refer this Github page for MQTTRoute MongoDB connector.

    MQTT Broker Tutorial – Extendability

    The features of MQTT Route is provided with certain extensions to make it flexible for users. You can customize it based on your needs.

    Remote Authentication:

    By default, the authentication of devices is done by the Broker. But, if authentication needs to be done outside the Broker, then this option can be used by setting in Bevywise/MQTTRoute/conf/broker.conf

    • Go to ./MQTTRoute/conf (Path may vary)
    • Open broker.conf
    • Make sure AUTHENTICATION_ENABLED is set to Yes
    [AUTHENTICATION]
    AUTHENTICATION_ENABLED = YES
    # YES || NO

    Then, set REMOTEAUTH_ENABLED to Yes

    [REMOTEAUTH]
    REMOTEAUTH_ENABLED = YES
    # YES || NO
    INTERCEPT_FILEPATH = ./../extensions/custom_auth.py

    In this case, the Username/Password sent by devices are received at the method handle_Device_Auth (username, password, clientid, ipaddress) defined in a Python file whose path can be set in INTERCEPT_FILEPATH in broker.conf.

    A sample file with this method(handle_Device_Auth()) definition is available in Bevywise/MQTTRoute/extensions/custom_auth.py, where this method is defined to send Username, Password, ClientId and IP address via POST Request to an external API which does the authentication.

    This method can be modified to suit the needs, if required.

    Note : You can also implement this method in your own file & specify the path in INTERCEPT_FILEPATH in broker.conf

    Custom Data Store

    AI / ML plays a major role in any IoT Implementation. So the data received from the different sensors need to be modeled and stored to any BIG data engine for further analysis and decision making. MQTT Route provides an option called the custom store to receive data at the back end to be stored as needed.

    Custom Store implementation is used to hook the received payload from MQTTBroker and store the payload in any of your analytics / big data engine. To configure, you must enable the CUSTOM STORAGE in data_store.conf.

    You need to enable CUSTOM STORAGE to receive the data of the message received from the devices into a python call back handle_Received_Payload (data) . This method need to be implemented in the python file specified in the INTERCEPT_FILEPATH.

    The data will be passed in a JSON format with the following keys – ‘sender’, ’topic’, ‘message’, ‘unixtime’, ‘timestamp’

    Your implementation should receive the data and store it and return the method. We advice you to just store the data or hand over the data to a stream analysis and return the method handle. Below is the custom_store.py file

    extensions/custom_store.py
    # Importing the custom class into the handler
    from customimpl import DataReceiver
    datasend = DataReceiver()
    def handle_Received_Payload(data):
    # Write your code here. Use your connection object to
    # Send data to your data store
    print “print in the handle_received_payload” , data
    result = datasend.receive_data(data)
    # if result is none then write failed
    def handle_Sent_Payload(data):
    # Write your code here. Use your connection object to
    # Send data to your data store
    print “print in the handle_sent_payload” , data
    result = datasend.sent_data(data)
    Custom UI server

    UI custom server provides an option to customize the user interface. You can alter the code in Custom_ui_server.py file as you need to customize it. You will be able to configure your dashboard to view device data as per your needs. You can add your own requirements, device details or notifications to the user interface as required. The UI custom server will help you customize the UI of the MQTTRoute by adding your own code on the server-side. Add your new functionality using the URL and the corresponding method. These URLs can be invoked from your User Interface for manipulating data.

    custom_ui_server.py
    #
    # Configure your additional URLs here.
    # The default URLs are currently used for the UI
    . # Please don’t remove them, if you are building it over the same UI.
    # def custom_urls( ):
    urllist={
    “AUTHENTICATION” : ‘DISABLE’,
    “URL_REDIRECT”: “/”,

    “urls”:[
    {“/dashboard/” : dashboard},
    {“/bwiot/extend-ui/create-dashboard/”:create_dashboard},
    {“/bwiot/extend-ui/get-dashboard/”:get_dashboard},
    {“/bwiot/extend-ui/delete-dashboard/”:delete_dashboard},
    {“/bwiot/extend-ui/widget/” : get_widgets},
    {“/bwiot/extend-ui/create-widget/” : create_widget},
    {“/bwiot/extend-ui/delete-widget/” : delete_widget}
    ]
    }
    return urllist

    # write your url function codes in the following methods
    def method( ):
    return ( “BEVYWISE NETWORKS” )

    def method1( ):

    return ( “BEVYWISE NETWORKS” )
    def method2( ):
    return ( “BEVYWISE NETWORKS” )

    Custom Scheduler

    The Scheduler allows easier scheduling of tasks to be broadcasted. Scheduler can be configurable by the user using the custom_scheduler.py file. The Custom Scheduler will help you create your own schedule in MQTTRoute by adding your own code on the server-side. SQL connector will be provided as cursor global variable for querying the Database & Elastic Search connector for querying Elastic if you have enabled custom storage option.

    custom_scheduler.py
    def schedule_conf( ):

    # ENABLE/DISABLE YOUR SCHEDULE
    #Add your schedule time in MINUTES in ‘OnceIn’
    #Add your method to call on schedule in ‘methodtocall’

    schedules={}

    schedules={
    ‘STATUS’ : ‘DISABLE’,
    ‘SCHEDULE’ : ‘DISABLE’,
    ‘TIME-SCHEDULE’ : ‘DISABLE’,
    ‘SCHEDULES’ : [
    {‘OnceIn’ : 1,‘methodtocall’ : oneminschedule },
    {‘OnceIn’ : 5,‘methodtocall’ : fiveminschedule } ] }

    return schedules
    #
    # SQL Connector. It will be sqlite / mssql / mysql cursor based
    # on your configuration in db.conf
    # Please construct your queries accordingly.
    global db_cursor
    #
    #Client object. It used to send/publish message to any active clients
    #Simply call the function with parameters like User_name, Client_id, Topic_name, Message, QOS,
    global Client_obj

    #
    # elasstic_search cursor.
    #
    global elastic_search
    # Called on the initial call to set the SQL Connector

    global web_socket
    # Web_socket
    def setsqlconnector ( conf ):
    global db_cursor
    db_cursor=conf [ “sql” ]

    def setelasticconnector ( conf ):
    global elastic_search
    elastic_search=conf [ “elastic” ]
    def setwebsocketport ( conf ):
    global web_socket
    web_socket=conf [ “websocket” ]
    def setclientobj ( obj ):
    global Client_obj
    Client_obj=obj [ ‘Client_obj’ ]

    def fiveminschedule ( ):
    pass
    #Write your code here
    #print “extension print”

    def oneminschedule ( ):
    pass
    #Write your code here
    #print “5 mins extend”
    SYS TOPIC

    Bevywise MQTT Broker performs SYS topic, which helps developers monitor the present status of the MQTT Broker rapidly.

    MQTTRoute periodically publishes information about itself to SYS Topics.

    To enable this, set in Bevywise/MQTTRoute/conf/broker.conf

    [SYS_TOPIC]
    SYSTOPIC = ENABLED
    SYSTOPIC_INTERVAL = 3

    The SYS topics that are supported and sample messages are listed.

    TOPIC MESSAGE
    $SYS/broker/version Bevywise MQTTROUTE Version 4.0
    $SYS/broker/uptime 0 days 0 hours 2 minutes 15 seconds
    $SYS/broker/clients/active No of Clients online: 1
    $SYS/broker/clients/total Total Client Count: 1
    $SYS/broker/messages/receive Total Packets received: 10
    $SYS/broker/messages/sent Total Packets Sent: 7
    $SYS/broker/subscriptions/count Total Subscriptions: 2
    $SYS/broker/Total_ACK/sent Total ACK sent: 10

    A device can start receiving these messages after subscribing to one or more of these topics, or to ‘$SYS/#’ or ‘#’.

    High Availability in MQTTRoute

    To ensure High Availability, more than 1 MQTTRoute Brokers can be used. Our MQTTRoute with the built-in Inter-Broker Communicator (IBC) enables all the brokers in the cluster to talk to each other ensuring continuous communication with the devices both ways irrespective of clients getting connecting to any broker in the cluster.

    A load balancer can be set up at the device-facing edge to balance the load.

    To learn more about the inter-broker communicator functionality, read our high availability blog.

    To enable High Availability in MQTTRoute, you should activate the inter-broker communicator first.

    Activate Inter-Broker Communicator

    The built-in Inter-broker Communicator (IBC) feature ensures seamless communication among all brokers within a cluster. This guarantees continuous connectivity with devices in both directions, regardless of which broker clients connect to.

    To enable IBC after installing MQTTRoute on broker machines, modify the configuration in Bevywise/MQTTRoute/conf/broker.conf as follows:


    IBC_Enable = YES
    Port = 8082

    The illustration below demonstrates the setup:

    HA architecture


    In this arrangement, two or more brokers with IBC enabled are grouped to form a cluster. A load balancer is then configured to distribute workloads evenly across these brokers. All MQTT brokers within the cluster remain active, and IBC within each broker ensures persistent communication by utilizing a shared database (DB). This means that brokers do not directly communicate with one another. Instead, they push data to the central database, allowing other brokers to access this data. As a result, every broker has access to client details and data.

    Note: You have the flexibility to select any load balancer that suits your needs.

    For a more comprehensive understanding of Nginx load balancer configuration, we recommend checking out our detailed blog on high availability.

    If you've opted to use Azure as your load balancer, we suggest referring to our dedicated blog post on Azure load balancer configuration for enhanced clarity.

    How to enable support for MQTT Payload of type ProtoBuf?

    Refer the following Github page for enabling Protobuf support.

    Running Broker as a Service

    MQTTBroker as a Service in Linux

    To run the MQTTBroker as service, we need the Monit version 5.25. Monit is an open source dynamic monitoring tool for Linux systems which is used for monitoring and managing system processes. And also, it performs automatic maintenance or repair of a particular process (i.e., restarting the service) and execute significant informal actions in error conditions whenever necessary.

    Download & Install Monit

    $ sudo apt install monit

    $ sudo systemctl disable monit

    $ wget https://monit.com/monit/dist/binary/5.25.2/monit-5.25.2-linux-x64.tar.gz

    Extract the archive using the command below

    $ tar -xvzf < Download file> (For example -$ tar -xvzf monit-5.25.2-linux-x64.tar.gz

    Copy monitrc file and paste in below location

    $ sudo cp monit-5.25.2/con/monitrc/etc/

    $ sudo chmod 700 /etc/mmonitrc

    Enable Monit HTTP interface

    Enable the HTTP interface by un commenting the following lines in /etc/monitrc file.

    set httpd port 2812 and
    use address localhost # only accept connection from localhost (drop if you use M/Monit)
    allow localhost # allow localhost to connect to the server and
    allow admin:monit # require user ‘admin’ with password ‘monit’

    If you want you can change admin:monit with username and password you want to use

    Start Monit

    $ cd monit-5.25.2/bin/

    $ sudo pkill -9 monit

    $ sudo ./monit

    Open Monit UI using the below URL in your web browser http://localhost:2812

    MQTTBroker as a Service in Windows/Windows server
    • Set the environmental variable for runbroker.bat and MQTTRoute.exe
    • Right-click My computer and select “Properties”.
    • Click “Advanced System Variable” from the left side panel.
    • In “System Properties” pop-up, click the “Advance” tab and click the “Environmental Variable” button on the bottom.
    • In “Environmental Variable”, select Path from system variables and click Edit.

    In that add,


    • runbroker.bat path[ installation path/Bevywise/MQTTRoute/bin]
    • MQTTRoute.exe path[ installation path/Bevywise/MQTTRoute]
    • Click Ok.
    • Next, open the “Task Scheduler”
    • In the Task scheduler window, right-click the “Task Scheduler” on the left panel and select “Create Basic Task”.
    • In “Create Basic Task” wizard,
    • First, give a Name and Description for the Task and click next.
    • Select “When the computer starts” and click next.
    • Select “Start a program” and click next.
    • In Program/Script, click Browse and specify runbroker.bat path[ installation path/Bevywise/MQTTRoute/bin]. Click next.
    • Select the “Open the Properties dialog box for this task” checkbox and click Finish.
    • Next, “In Properties” dialog box will open. In that select “General” tab and select “Run whether the user is logged on or not”. Also, enable “Run with highest privileges” checkbox.
    • Next, select “Condition” and uncheck all the checkboxes.
    • Select “Setting”, enable “If the task fails, start every:” checkbox and select the time interval [default min time is one min] and uncheck all other checkboxes.
    • Next click ok to save the properties.
    • Once you install the MQTTBroker will set to “startup program”, which means it will start when the PC starts. So we must remove MQTTBroker form “Startup program”.
    For Windows 7 or higher:
    • Click start and search “System Configuration”
    • In that wizard, under “startup”, click ” Bevywise MQTTRoute” and disable it.

    For Windows Server 2012R2 or higher:
    • Press “windowskey+r” to open the run window.
    • In that type “shell:common startup” and click OK.
    • Now the Startup window will open. In that delete the Bevywise MQTTBroker and close the windows.
    • Next Restart the PC. Now the Broker will run as a service via Task scheduler.

    To check:

    • In the command prompt, type “netstat -a” and press enter.
    • In output, you can see 0.0.0.0:1883, 0.0.0.0:8080, 0.0.0.0:8081 port are running. [1883 -MQTTBroker, 8080 – MQTTBroker UI, 8081:Client connection].
    MQTT Gateway

    This section of the MQTT Broker tutorial explains the functions and the options to work with the Gateway bundled with the MQTT Route. The MQTT Gateway acts as an intermediate agent between the Sensors and the MQTT Broker. The MQTT Gateway has inbuilt functionality to discover all the sensors that run around the gateway. The gateway advertises itself and its Clients will be able to search for the gateway in return.

    The gateway can be started in two modes :

    Aggregated Gateway – The gateway will make only one connection with the central MQTT Broker and will aggregate all the messages from the individual sensors and send it to the broker via the single connection. This will reduce the load on the Central Broker.

    Transparent Gateway – This gateway will just act as a forwarding agent and each sensor will be individually connected to the central broker.

    The gateway supports the accumulation of messages when the client goes for a sleep state and sens all the messages when the client comes back.

    Note : Without Bluetooth, MQTT Gateway will not work. So, enable Bluetooth in your PC and follow the below steps.

    To start MQTT Gateway :

    Start the Gateway after starting the MQTT Route.

    For Windows :

    • Double click the “rungateway.bat” file inside the Bevywise/MQTTRoute/bin folder.
    • (or)
    • Open cmd and go to Bevywise/MQTTBroker/bin folder. Then, type “rungateway.bat” and hit enter.

    To start MQTT Gateway in other OS :

    • Open the terminal and go to Bevywise/MQTTRoute/bin
    • Type “sh rungateway.sh” and hit enter.
    • Configuring Bevywise MQTT Gateway

    The Gateway can be configured using the gateway.conf file inside the conf folder.

    conf/gateway.conf
    [SERVER_CONFIG]
    PGATEWAY_NAME = “gateway1”
    SERVER_TLS_ENABLED = FALSE
    # True to enable TLS and listen SERVER_TLS_PORT & False to disable TLS and listen SERVER_PORT.
    SERVER_IP = 127.0.0.1
    SERVER_PORT = 1883
    SERVER_TLS_PORT = 8883
    # TLS_PORT must be 88xx.
    SERVER_AUTHENTICATION_ENABLED = FALSE
    USERNAME = Hello
    PASSWORD = hello
    # Gateway config to MQTT Client.
    [GW_MQTT_LISTEN_CONFIG]
    GW_MQTT_ENABLED = TRUE
    # True to listen MQTT Client & False to disable MQTT Client.
    GW_TLS_ENABLED = FALSE
    # True to listen MQTT client in secured channel.
    GW_MQTT_PORT = 1884
    # Gateway config to MQTTSN Client.
    [MQTT_SN_CONFIG]
    GW_MQTT_SN_ENABLED = TRUE
    # True to listen MQTTSN Client & False to disable MQTTSN Client.
    GATEWAY_TYPE = TRANSPARENT
    #AGGREGATED || TRANSPARENT
    # multicast Address for Gateway
    GW_GROUP_ADDR = 224.2.2.1
    GW_GROUP_PORT = 1883

    # multicast Address for SN Clients
    SN_GROUP_PORT = 1884
    SN_GROUP_ADDR = 224.3.3.1
    GW_PATH_TO_PREDEF_TOPIC = ./conf/predefined_topics.txt
    # set the predefined Topic name and id in the file.
    # Format:
    MySQL Installation
    For Linux Users

    To check whether MySQL is already installed or to open the MySQL monitor, follow the below steps.

    • Open Terminal
    • Type the following command : $ mysql -u root -p
    • Enter the Password as root which is the default one
    • This will let you know whether MySQL is already installed or not.
    • If MySQL is installed already, then check installing MySQL connector tab.
    • If it is not installed, then download and install MySQL.
    • You can download your suitable MySQL package.
    • Download the package using the following wget command :

    wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb

    terminal

    Install the MySQL package by executing the below command :

    sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb

    Package configuration window will appear. In that choose the first option and click Ok.

    configuration box

    In the next window, select your desired product and hit Enter to continue.

    Select the last option and press Enter to proceed further.

    mysql box

    Next step is to update the APT repository. Use the following command to update it :

    sudo apt update

    terminal
    Install MySQL Server & Client

    If needed, you can install MySQL Server and client. You need to run the below command to install MySQL server and client. Press ‘Y’ to begin the installation. Provide password for the root user when asked.

    sudo apt install -f mysql-client=8.0* mysql-community-server=8.0* mysql-server=8.0*

    In the next window, provide a password for the root user. Go through the information about the authentication system based on SHA256-based password methods. Then choose the authentication plugin. The installation gets started and MySQL 8.0 will be installed in your system.

    MySQL is successfully installed. Use the below command to access MySQL monitor or to verify the installation of MySQL

    $ mysql -u root -p

    Installing MySQL Connector :

    To integrate MQTT Broker with MySQL we need to have certain dependencies installed.

    To make it easy we do provide installer file named install_mysql_connector.sh which on running will automatically install all required dependencies in your system.

    You can find the file inside .Bevywise/MQTTRoute/bin.

    Run the file using the command below

    sh install_mysql_connector.sh

    terminal

    Now the MySQL connector is installed in the required repository. Then its time to configure MQTT Broker to accept MySQL as a database. Please check the MySQL configuration tab.

    For Windows/Windows server users:
    • Download and install WGET from [https://eternallybored.org/misc/wget/]. In that webpage download wget-1.20 zip and extract it.[version 1.20]
    install WGET
    • From the desktop, right-click ‘My Computer’.
    • Choose ‘Properties’ from the context menu.
    • Click the ‘Advanced system’ settings link.
    advanced settings
    • Click ‘Environment Variables’. In the section System Variables, find the PATH environment variable and select it. Click ‘Edit’. If the PATH environment variable does not exist, click New.
    system properties
    • In the ‘Edit System Variable’ (or New System Variable) window, specify the path where wget.exe located. Click ‘OK’. Close all remaining windows by clicking OK.
    my computer
    • Open cmd and go to ./Bevywise/MQTTRoute/bin
    • Type install_mysql_connector.bat and hit enter, this file will install all the dependencies which are required to establish the connection between MQTTBroker and MySQL
    • Dependencies installed after running the “install_mysql_connector.bat” file are :

    1. Python 3.7

    2. Pip 3.7

    Note: The above dependencies shall be skipped if it is already installed on PC.

    Install MySQL 5.7 server or higher.

    • Go to ./Bevywise/MQTTRoute/conf and data_store.conf
    • In data_store.conf change as follows
    MySQL

    DB_SERVER = MYSQL

    MYSQL_USER= < username >

    MYSQL_PASSWORD = < Password >

    Note: Please don’t use XAMPP or MAMP for MySQL.

    Python installation in windows

    Once you run the installer.bat file, python3 will automatically download and the installation will start.[Python installation steps shall be skipped, if it was already installed]

    Follow the below steps to install python3:

    • At first, you can see the following window. In that, select the first option and click next.
    install python

    • The next dialog will prompt you to select whether to Disable path length limit. Choosing this option will allow Python to bypass the 260-character MAX_PATH limit. Effectively, it will enable Python to use long path names.
    python setup

    • The Disable path length limit option will not affect any other system settings. Turning it on will resolve potential name length issues that may arise with Python projects developed in Linux.
    • Once the above step is completed, the installation of the Python 3.7 will start on your Windows 7 machine.
    • When the setup is close to the finish, just click the Finish button.
    MQTTRoute App

    We pack variety of features & functions in MQTT Broker app to visualize, monitor & control MQTT devices / data on your smart phone. The new mobile app works in conjunction with MQTTRoute that helps you take complete control over your MQTT-enabled devices connected to the MQTTRoute. MQTTRoute App is available on Google Play Store. Here is the direct link to install MQTTRoute App from Play store.

    Download & install our app from Google play store on your android smart phone.

    install app

    Define the IP / Domain in which the MQTTRoute is running

    define IP

    Provide the Username and Password of your MQTT Broker. By default, Username – admin, Password – admin. If you have changed the username & password already, use that.

    web login

    Once done, you will be able to access the MQTT Dashboard with the latest happenings in the MQTTRoute.

    broker dashboard

    Start accessing & creating a dashboard specific to your application. You can create multiple dashboards & configure the user interface in the way you need.

    Default Dashboard

    View Device details, Events, recent connects & disconnects & more in the Dashboard.

    Dashboard Creation

    To visualize data specific to your application, create & develop multiple dashboards with pre-built widgets.

    Click ‘+Dashboard’ & follow the steps mentioned in custom dashboard section to create multiple dashboards with widgets.

    add dashboard

    Enter Dashboard name that you are yet to create and provide ‘Description’.

    create dashboard

    Now click ‘+ widget’ & choose your desired widget from the list.

    create widget

    Then enter the necessary details about the device for which you need to visualize data. Here we have attached screenshots on creating Line widget. The same steps should be followed for all the available widgets.

    widget types

    widget details

    widgets

    widgtes
    Additional Information on Application Integration

    Bevywise MQTT Broker works seamlessly with any application. The below mentioned articles provide step by step instructions to integrate MQTT Broker with such applications.

    MQTTRoute Package Structure

    This gives you the details about the MQTTRoute Product Package. When you unzip the file, a folder named ‘Bevywise’ will be created. The contents of the Broker are in Bevywise/MQTT_Broker location.

    bin/

    This folder contains the executable file required to run Bevywise MQTTBroker. The runbroker.sh file runs the broker using the python executable file.

    Certificate/

    This folder contains a secure SSL/TLS certificate. The client and server contain a common CA certificate root.crt file which is the Certificate Authority to verify the clients and the server. client/ will have the client.crt certificate file and client.key file for the certificate. server/ will have a server.crt certificate file and server.key key file for the certificate.

    conf/

    In this folder, the configuration file for the broker is stored. The properties like Broker Port, TLS Port, Enable/Disable TLS and Authentication of the user can be configured using the broker.conf file.

    data/

    This folder contains the SQLite database that stores all the details of the broker. When the broker runs, the database is created.

    lib/

    This folder contains the core libraries of Bevywise MQTTBoker.

    license/

    This folder contains the open source license agreement and license file of the MQTTBroker libraries.

    ui/

    This folder contains the required files for the User Interface. You can see the user interface from your browser using 127.0.0.1:8080.

    README

    A text file which guides the user step by step to run the Bevywise MQTTBroker.

    How to upload the license ?

    This section is for premium users who bought license from us for the advanced use of MQTTRoute functionalities.

    The premium users will be provided with license.dat file to be uploaded in MQTTRoute.

    • Go to /../MQTTRoute/license
    • Upload the license.dat file provided
    • Restart the MQTTRoute

    Your license is upgraded now. To verify, run the MQTTRoute in terminal. Terminal displays the premium version you are using.

    Have More Questions?

    We are with all ears waiting to hear from you. Post us with your questions and feedback.