The RSMB MQTT-SN broker written by Ian Craggs of IBM isn’t currently being actively developed, but it is still invaluable for anyone wanting to get experience using MQTT-SN.
The RSMB broker functions both as a MQTT-SN broker and also as an MQTT broker allowing messages between MQTT-SN clients and MQTT clients, as shown in the diagram below:
An MQTT-SN client can publish on a topic that can be received by an MQTT-SN client or an MQTT client subscribed to that topic.
Likewise; An MQTT client can publish on a topic that can be received by an MQTT-SN client or an MQTT client subscribed to that topic.
The demo python scripts in the downloads illustrate this.
Installing the Broker
You can download the RSMB ( Really small message broker here . Unzip it.
When you unzip it you should see a directory structure like the one below:
Open the RSMB folder and go to the src folder:
In the src folder you will find the source files (.c and .h files), it also contains a Makefile that contains instructions to build the broker.
Navigate to this directory and run make to compile the broker.
Note: On Linux the compiler will already be installed and so this will work. However on Windows you will need the necessary software installed. I have only done this on Linux.
You get two brokers called broker and broker_mqtts.
The broker program only supports MQTT over TCP.
The broker_mqtts is the one you need to run MQTT-SN.
I copied the broker files into a directory of their own and created a configuration file called text.txt.
In the configuration file I turned on detailed logging and set the broker port for 1884 just to test it. here is the file.
To run it at a command prompt type.
If you want the broker to advertise the Gateway address then use this config file.
trace_output protocol # normal MQTT listener listener 1883 INADDR_ANY # MQTT-S listener listener 1885 INADDR_ANY mqtts # optional multicast groups to listen on multicast_groups 220.127.116.11 #This will advertise the Gateway address to clients # optional advertise packets parameters: address, interval, gateway_id advertise 18.104.22.168:1885 30 33
Notice that in the config file above MQTT uses the standard port 1883:
listener 1883 INADDR_ANY
and MQTT-SN uses port 1885.
listener 1885 INADDR_ANY mqtts
advertise 22.214.171.124:1885 30 33
sets port 1885 as the multicast port and it is the same as the UDP port. However they can be different.
You will need to configure the MQTT-SN client to listen on port 1885 and Multicast IP of 126.96.36.199 to receive the multicast messages.
This is what the output of the Python client shows when gateway is found
64 bit Processors
If you want to run it on a 64 bit processor it may fail with a strange warning that it can’t find the file.
On Ubuntu you need to do the following:
Screen shot above taken from this forum post.
From the documentation and my testing The broker does not support the following:
- QOS 2
- clean sessions
There aren’t any free MQTT-SN brokers as far as I am aware.There is a Gateway available and released by the Eclipse foundation.
Video – RSMB and Python MQTT-SN Client Demo
Common Questions and Answers
Q -Can I use the MQTT-SN broker as a MQTT broker?
A – Yes provided it is enabled in the config file
Q -Does a client use the same UDP port for sending MQTT-SN messages as used by the Advertisement Multicast messages.
A – It depends on the configuration file>they can be the same or Different.
Q- Do I need to use the advertise feature?
A- No it is optional
There is a very useful getttingstarted.htm file in the doc folder.
Related Tutorials :