Getting started with MQTT-SN in RSMB

Now that the source for RSMB with MQTT-SN is available, here is the quickest of quick starts to get going with MQTT-SN. More to come in due course.

The source is at
in the rsmb directory. To build, go into rsmb/src and call “make”. That works well for Linux. You need a make from cygwin or similar to build for Windows.

This is an example configuration file for RSMB with MQTT-SN:

# will show you packets being sent and received
trace_output protocol						

# normal MQTT listener
listener 1883 INADDR_ANY	
# MQTT-S listener
listener 1884 INADDR_ANY mqtts					
	# optional multicast groups to listen on
	# optional advertise packets parameters: address, interval, gateway_id			
	advertise 30 33			

# MQTT-S outgoing multicast bridge (QoS -1)
connection mqtts_multicast						
	protocol mqtts_multicast  
	# only one address is used at the moment, plan is that a list can be used
	topic a out
	topic abcdef out

# QoS 2 MQTT-S bridge
connection mqtts							
	protocol mqtts
	topic a out

At the moment predefined topics and sleeping clients aren’t implemented.

There is a Python MQTT-SN client in rsmb/src/MQTTSClient/Python – see, in the main section, for an example of using it.

35 Replies to “Getting started with MQTT-SN in RSMB”

  1. Thanks for the instructions. Sadly I can’t get it to work. I have tried on Debian Linux and Mac OS X:

    20131124 215009.143 CWNAN0124I Starting bridge connection mqtts
    20131124 215009.143 4 star.mqtts -> MQTT-S CONNECT cleansession: 0 (0)
    20131124 215009.144 CWNAN0075W Socket error 111 (Connection refused) in UDP read error for socket 4
    20131124 215009.144 CWNAN0018W Socket error for client identifier star.mqtts, socket 4, peer address; ending connection
    20131124 215009.144 CWNAN0099I Trying bridge connection mqtts address again, without private protocol

    Any idea what is wrong?

    1. So I just did this (on RedHat, Intel). First RSMB has outgoing bridge:

      connection mqtts
      protocol mqtts
      topic a out

      Second RSMB has listener on matching port:

      listener 1885 INADDR_ANY mqtts

      Then the MQTT-SN bridge connected to the other broker. Two things to watch out for:

      1) To build RSMB on some platforms (not the usual ones) you need the -DREVERSED compiler flag. This because I use bitfields in the MQTT packet processing. Whether you need it is entirely arbitrary – processor architecture can affect it. If any client, MQTT or MQTT-SN can connects, you’re ok.

      2) Firewalls often block multicast traffic. In this case we’re not using multicast of course.

    1. Ha ha. Soon my friend, we’ll have the new spec out, and the name will be officially changed, and I’ll update it all!

  2. Hello Ian,

    first of all, thank you for all of your MQTT and RSMB posts. Now, iยดve got a question regarding the configuration of the RSMB using MQTT topic names and MQTT-SN topic ids over a MQTT-SN gateway.
    Using the this post and the “Getting started with the Really Small Message Broker” information is very useful to figure out how to configure topic name mapping in the case of connecting two Really Small Message Brokers together.
    Regarding to the MQTT-SN specification v1.2 in section “6.10 Gateway’s Publish Procedure”, the gateway (in my case the RSMB, using the broker_mqtts implementation) may send a REGISTER message to inform the client about the topic name and its assigned topic id value. Now, i would like to configure the mapping of MQTT topic names to pre-defined MQTT-SN topic ids.
    Is it possible to configure a mapping in the RSMB broker.cfg configuration to tell a MQTT-SN client the pre-defined topic id after a successful connection to the RSMB?

    Thank you for your feedback.


    1. Hello Dennis,

      thanks for your question. The short answer is unfortunately no :-(. Predefined topics are one of the two MQTT-SN functions, the other being sleeping clients, that were not yet implemented in RSMB. My plan is that all the MQTT-SN functions would be added to a) Mosquitto, when it has MQTT-SN added and b) an MQTT-SN to MQTT transparent gateway which I plan to add to Paho.

      However, adding pre-defined topic ids to RSMB should not be a big task, and I would gladly accept a contribution. Or I might get to it myself as a stop gap until Mosquitto supports MQTT-SN itself.

  3. Hi Ian,
    I’m using RSMB as a MQTT/MQTT-SN bridge and seems I’ve found a serious bug in connection handling logic for MQTT-SN clients there. If you still supporting it, I can provide details on the bug.
    Thank you for this great project!

  4. Hi Ian,

    First, thank you for the great work and info provided on MQTT(-SN) and RSMB. Great work!

    Now, I’m probably missing something, but shouldn’t the Python client support qos = -1?

    Specifically, with:

    aclient.publish(1, “aaaa”, 0)

    everything works fine, however, using:

    aclient.publish(1, “aaaa”, -1)

    the following error occurs:

    Traceback (most recent call last):
    File “./”, line 33, in
    aclient.publish(1, “aaaa”, -1)
    File “/root/rsmb/rsmb/src/MQTTSClient/Python/”, line 180, in publish
    File “/root/rsmb/rsmb/src/MQTTSClient/Python/”, line 491, in pack
    buffer = self.Flags.pack()
    File “/root/rsmb/rsmb/src/MQTTSClient/Python/”, line 107, in pack
    (self.Will << 3) | (self.CleanSession << 2) | self.TopicIdType )
    ValueError: chr() arg not in range(256)

    Should I open a ticket or is it simple misuse?


    1. Hello Joao,

      that looks like a bug, so please open a ticket. In fact, I’d forgotten that I’d put the Python MQTT-SN client into the RSMB repository! I think I’ll be moving it to Paho soon, with the other client implementations.

      1. Hello Ian,

        Thank you for your quick reply. Sure, I will open the ticket.

        I’ve been playing around with your Python MQTT-SN client and Nicholas mqtt-tools but your reply reminded me the existence of Paho Embedded MQTT-SN C/C++ Client! Thank you for that too! ๐Ÿ˜‰


        1. Hey Ian,
          can you please tell me which MQTT-S broker should i go for Raspberry Pi2 board. i m bit confused, This is my first programming project. Im dummy in this API’s so far.
          Though i did understand the Command Structure.

          Can you please suggest and help with a basic simple code or place me in right direction?

          1. You can get RSMB running on the Raspberry Pi 2 like this:

            git clone git://
            cd rsmb/src

            then you will have an executable: broker_mqtts.

  5. Hi,

    I guess I found a mistake in the Python client. If I try the I can’t unsubscribe a client from a topic. I guess it’s the line 146 in the unsubscribe method, where the “topic” is assigned to “” instead of “unsubscribe.TopicName”. Changing this solved the problem.

    Best regards,

  6. Hi Ian,
    I’m trying to get rsmb working on a raspberry pi. I’ve tried your instructions but get the following error: fatal: [source]/info/refs not found: did you run git update-server-info on the server?
    Any thoughts on what I can do to resolve? Is rsmb only compatible with raspverry pi 2 and not raspberry pi?

    1. Hi Lea,

      did you build RSMB yourself, or get a precompiled binary? What were you attempting when you got this error? RSMB should be compatible with any Raspberry Pi, as long as it’s built correctly.


  7. hi lan,
    i have install the RSBM in RaspberryPI and add a config file call mqtt-sn.conf
    when i enter ./broker_mqtts mqtt_sn.conf
    it throw error
    20160310 123828.692 CWNAN9999I Really Small Message Broker
    20160310 123828.692 CWNAN9998I Part of Project Mosquitto in Eclipse
    20160310 123828.692 CWNAN0049I Configuration file name is mqtt-sn.conf
    20160310 123828.692 CWNAN0053I Version, Nov 22 2014 12:37:37
    20160310 123828.692 CWNAN0054I Features included: bridge MQTTS
    20160310 123828.692 CWNAN9993I Authors: Ian Craggs (, Nicholas O’Leary
    20160310 123828.692 CWNAN0000W Could not read configuartion file mqtt_sn.conf
    20160310 123828692 CWAN0047I Broker stopped

    Do you know what problem cause it? Also how to solve.
    Many thanks

    1. Well I note that you say you created a file called mqtt-sn.conf (with a dash) but then started RSMB by telling it the file name is mqtt_sn.conf (with an underscore). Maybe it is simply the wrong filename?

  8. Hi Mr Ian ,
    Im trying to find how to set up a MQTT-SN BLE (Bluetooth Low Energy ) gateway on a Raspberry Pi 2 , should I use the RSMB MQTT-SN ? is there any configuration file example for Bluetooth ?

    1. RSMB only support MQTT-SN over UDP. You could try the Eclipse Kura project, which I believe has bluetooth support, or there is a newly contributed MQTT-SN gateway to the Eclipse Paho project, which is intended to be portable to transports other than UDP.

  9. Ian,

    First of all Thank you so much for your contribution!. I am wondering if rsmb’s MQTT-SN broker can be bridged to AWS IoT MQTT broker. I know this can be done with Mosquito MQTT broker using the certs.

    I am wondering if such configuration to provide the certs is enabled in the RSMB’s mqtt-sn.conf.

    Or do I need to go MQTT-SN Broker โ€”>another MQTT Broker(Mosquito) โ€”> AWS IoT.

    Any recommendations?

    1. Hi. RSMB doesn’t have TLS support because I was expecting Mosquitto to take on its role. I think that TLS is needed to connect to AWS? Unfortunately, it’s been harder than expected for Roger to add MQTT-SN support.


      1) bridge from RSMB to Mosquitto and then to AWS
      2) a new MQTT-SN bridge is being contributed to Paho. The idea of that is to be able to use it to connect to Mosquitto or other MQTT brokers

  10. Good day.
    Could You help me.
    Collect samples in Eclipse.
    After trying the connection on the local computer to get the answer –

    1. Sorry – for some reason not added the message from rsmb.
      – Duplicate connection attempt received for client identifier “AlexTest” from address, ending oldest connection

      1. If you have two client applications with the same clientid that try to connect at the same time, you will see this message. It’s what the MQTT specification requires – to throw off the previously connected client.

  11. Hi Ian,
    a bit off-topic, sorry.
    I don’t really expect you remember me, I contributed small samples and minor changes for the embedded-C MQTT and MQTT-SN libraries years ago (being low-level transport agnostic).
    Besides saying hi, I wanted to ask you if I can use your 2015 presentation for EclipseCon (or slides of it) for an event we’ll be having down here in Argentina in late november. Although the event will be Quectel-centric, I’ll be showing MQTT and MQTT-SN to some local developers.
    I’ve been very busy on non-related projects, but I plan to add some lwIP samples in the not so far future (they are already done…).
    Best regards!

    1. Hi Sergio, I do remember you, and thanks for your contributions! Yes, I would be happy for you to use my slides. Do you have them already?

  12. Hi Ian Craggs,
    Thank you for this guide to use RSMB broker. I am also working over RSMB broker. I have installed RSMB broker in raspberry pi 3 & Mosquitto broker is also running over raspberry pi. I have created a bridge in between RSMB broker & raspberry pi so that when I send UDP packet on a topic, the packet can be transmitted over mosquitto broker.
    The bridge connection has successfully established but when I am sending UDP packet to RSMB broker on the MQTT-SN port, it is throwing me an error:
    CWNAN0075W Socket error 107 (Transport endpoint is not connected) in getpeername for socket 4
    CWNAN0021W Badly formed packet on socket 4, peer address unknown; ending connection
    I have googled about this error but not getting complete idea about how can I resolve this error. It would be great if you can provide me any solution. Thank you ๐Ÿ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *