MQTT Broker, a Coreflux Flux Asset
The Purpose of this Flux Asset
The main purpose of this asset is to provide a simple MQTT broker based on TCP/IP. The asset is, in fact, a message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Lightweight and suitable for use on all devices, you can use it in low-power single board computers or full servers.
Glossary of Parameters (Configuration)
The parameters can be configured in the following ways:
Bind IP
In this setting we are able to define the LAN we want to provide MQTT service. If Bind IP is defined with 0.0.0.0, it enables all the interfaces… set the IP in order to select only one interface. This is very useful when you need to separate LANs and disable MQTT access from outside.
TCP Port
This MQTT broker is a simpler version that doesn't use Websockets, thus only being defined with a common TCP/IP connection. For additional functionality, use the WS MQTT Broker asset.
Client Timeout
This timeout closes the socket if no activity is found within the socket connection.
Persistent Connections
This setting enables Persistent Connection.
If the client enables this, the broker stores the following information (even if the client is offline).
- Existence of a session (even if there are no subscriptions).
- All the subscriptions of the client.
- All messages in a Quality of Service (QoS) 1 or 2 flow that the client has not yet confirmed.
- All new QoS 1 or 2 messages that the client missed while offline.
- All QoS 2 messages received from the client that are not yet completely acknowledged.
When the client reconnects, the information is available immediately.
Connection Backlog
This setting is used when multiple clients connect at the same time, and it defines the maximum queue clients at peak. For a small to medium size IOT project, this setting should not be changed. For a global concept connection, it might be required to increase the queue, which will increase the memory consumption.
Instance ID
In this field you can define a name for the broker. Coreflux will provide a random one, if it is left empty.
Example
Setting up a broker to Bind 192.168.1.xxx interface with 1883 port.
Fill in the configuration of the IP, port and Instance ID, with the name “Central Broker”.
The broker should be installed and up-and-running. It should be available as shown below (the lower left asset icon, titled “Central Broker”). Please ensure that you add Port 1883 to your firewall settings.
Start the instance, and experiment with MQTT Explorer to publish and check data.
For C# users please check :