Book A Demo Now

QoS2 and websockets support in rumqttd

QoS2 and websockets support in rumqttd
QoS2 and websockets support in rumqttd

With rumqttd v0.16.0, we now support Quality of Service (QoS) level 2, i.e. Exactly Once delivery, MQTT over websockets and better control over memory usage per subscription filter. Lets take a look at what this really mean and how they are helpful!


QoS2: Exactly Once delivery

QoS2 is the highest quality of service in which neither loss nor duplication of messages is acceptable. To assure that each message is delivered exactly once, it uses a two-step acknowledgement process:

Working of QoS 2

When publisher/sender publishes a message with QoS level 2, subscriber/receiver acknowledges that Publish with a PubRec ( Publish Recorded ) packet. Once the original publisher receives PubRec , it replies with PubRel ( Publish Release ). And finally PubComp ( Publish Complete ) is sent as acknowledgement to PubRel by the receiver to indicate that we have successfully published message.

This is a basic overview of QoS2, we won't  be going over it in depth in this post, if you want to read more about it, you can refer to MQTT OASIS standards here .

QoS2 is generally used in critical systems, when duplicate messages can have significant impact on the application, because it incurs additional overhead compared to other QoS levels.


MQTT over Websockets

We can connect to rumqttd over websockets ( ws:// ) or secure websockets ( wss:// ) protocol. It works by enveloping mqtt packets in websocket frames, just like how TCP does it.

MQTT over websockets

This enables lots of new possible use cases for rumqttd. As of writing the blog, we only support MQTTv3 over websockets, but configuring it to use MQTTv5 is quite simple, so it will be there soon. You can simply use rumqttd.toml for configuration.


Configure segment size per subscription filter

We can now configure max memory to be used by subscription filter segments in rumqttd. Before this, we could specify the size in rumqtt.toml like:

[router]
...
max_segment_size = 104857600
...

And this same max_segment_size will be applicable for every filter segment. This may end up consuming unnecessary memory as not all filters will need that much right? But now you can configure it per filter :

[router]
...
max_segment_size = 104857600 # this will be applied to rest of filter
...
# Any filters that matchs configured filter will have custom segment size.
    [router.custom_segment.'/office/+/devices/status']
    max_segment_size = 102400
    max_segment_count = 2
    [router.custom_segment.'/home/+/devices/status']
    max_segment_size = 51200
    max_segment_count = 2
rumqttd.toml

We are actively working on adding MQTTv5 features to broker, and would love if you wish to contribute! Feel free to open PR / issues. You can also join discord for discussing anything or just hanging out while we build the robust and blazingly fast broker.

Thank you for reading till end, hope you enjoyed it. Don't forget to star rumqtt on GitHub ( stars are beautiful, aren't they? ).