SolarNetwork

News » MQTT 5 now supported

SolarNetwork now supports MQTT version 5 for both SolarIn/MQTT and SolarFlux. The main benefit to users is that less network bandwidth is consumed, thanks to topic aliases. For example, in SolarFlux the MQTT topics are strings constructed by combining user, node, aggregate, and source IDs. They can grow quite long, and in MQTT before version 5 the full topic must be included with every message published. With MQTT 5 and topic aliases, the topic need only be sent once on a given connection, and afterwards a small integer takes the place of the full topic string.

For example, a typical SolarFlux topic like user/123456/node/123/datum/0/SITE34/BLD2/AREA51/UF0 requires 51 bytes per message. Once a topic alias is established, that can be reduced to an alias like 1 and require only 4 bytes per message (3 bytes of overhead plus the alias value itself). Over the life of the MQTT connection, that can amount to a significant reduction of consumed bandwidth.

Here’s an example of the difference of sending a datum using MQTT 5. The first message that is sent includes the topic, which is node/344/datum/0/OS Stats in this example. The message consumes 67 bytes:

         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 31 41 00 19 6e 6f 64 65 2f 33 34 34 2f 64 61 74 |1A..node/344/dat|
|00000010| 75 6d 2f 30 2f 4f 53 20 53 74 61 74 73 03 23 00 |um/0/OS Stats.#.|
|00000020| 01 0d 00 00 00 3f 1d 00 00 c7 42 2d 9a 99 2d 42 |.....?....B-..-B|
|00000030| 35 7b 14 ce 3f 3d 7d 3f 41 42 41 e1 7a 14 ae 07 |5{..?=}?ABA.z...|
|00000040| 4a b6 40                                        |J.@             |
+--------+-------------------------------------------------+----------------+

The next message sent omits the topic and uses an alias 1 instead and consumes only 42 bytes:

         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 31 28 00 00 03 23 00 01 0d 00 00 90 40 1d 00 00 |1(...#......@...|
|00000010| bf 42 2d cd cc 30 42 35 66 66 c6 3f 3d 7d 3f 41 |.B-..0B5ff.?=}?A|
|00000020| 42 41 1f 85 eb 51 78 65 b6 40                   |BA...Qxe.@      |
+--------+-------------------------------------------------+----------------+

That saves 25 bytes per message, and SolarNode might generate hundreds or thousands of messages per day, per source. Over time the bandwidth savings really add up to a significant amount.