VerneMQ and MQTT-SN

From time to time (though not very often) we get asked if VerneMQ supports the MQTT-SN protocol and the reply was always something like: "No, VerneMQ doesn't support MQTT-SN as there's just not enough demand for it".

That's of course annoying for those who need MQTT-SN and would like to use it with VerneMQ. In the following we'll explain a bit more in detail what MQTT-SN is, why we don't support it and what you can do to use MQTT-SN and VerneMQ anyway.

First, let's take a quick look at what MQTT-SN is. MQTT-SN stands for "MQTT for Sensor Networks" and is a protocol which is designed for devices where even MQTT might be too resource consuming. This is achieved by relaxing the requirements to the underlying protocol and not require ordered lossless connections like TCP/IP, as these can be too complex to handle for very small battery powered devices with limited processing power. MQTT-SN is therefore often implemented using UDP but should be able to run on most bi-directional network types.

So the people looking for MQTT-SN support are mostly looking for MQTT-SN on UDP.

Central to MQTT-SN is the concept of an MQTT-SN Gateway. An MQTT-SN gateway is a bridge translating between MQTT-SN and regular MQTT and fundamentally two different gateway types exist: transparent and aggregating gateways.

A transparent gateway maintains a direct mapping between MQTT-SN clients and MQTT connections to the MQTT broker and basically performs a simple translation between the two protocols.

An aggregating gateway maintains a single connection to the MQTT broker and all MQTT-SN client data is transformed into a single data stream communicated to the Broker.

An MQTT-SN gateway may or may not be integrated into an MQTT broker. The advantage of having it integrated into the MQTT broker is obvious: there is no need to configure any external components, just configure the MQTT-SN feature and you're done. The drawback, however, is that it assumes that all your MQTT-SN clients can reach the MQTT broker directly. Not having the MQTT-SN gateway integrated into the MQTT broker therefore has the advantage of being more flexible: the MQTT-SN gateway can be located close to the MQTT-SN clients or as a service on the same server as the MQTT broker. Another important advantage of having the possibility to locate the MQTT-SN gateway close to the MQTT-SN clients is that the connections between the gateway and the MQTT broker can be secured with TLS.

And this leads us back to trying to answer the original question "Why doesn't VerneMQ support MQTT-SN?"

The answer of course is one of pragmatism. If we were to add MQTT-SN to VerneMQ we would have to be convinced that it is worth the effort to allow it to take focus away from other areas. Our current "gut-feeling" is that most use-cases would require the MQTT-SN gateway to be located close to the MQTT-SN clients due to network restrictions and/or require the data to be encrypted which is easiest to achieve using plain MQTT with TLS. In those scenarios MQTT-SN in VerneMQ would not be a help.

So, until we have more data on the demand and usage patterns for MQTT-SN, adding MQTT-SN support is quite low on our list of priorities. To use MQTT-SN with VerneMQ anyway we recommed to use one of the standalone gateways out there, such as the excellent Eclipse Paho gateway transparent gateway.

For more information on MQTT-SN the specification for MQTT-SN 1.2 is available here. It's a relatively short read.

Leave a comment below with your thoughts on MQTT-SN and VerneMQ - we love to learn - especially if we're proven wrong!

Cheers & Forward!

Lars & The VerneMQ Engineers!