Keeping MQTT Data History with Node.js
The MQTT protocol is widely used in IoT applications because of its simplicity and ability to connect different data sources to applications using a publish/subscribe model. While many MQTT brokers support persistent sessions and can store message history while an MQTT client is unavailable, there may be cases where data needs to be stored for a longer period of time. In such cases it is recommended to use a time series database. There are many options available, but if you need to store unstructured data such as images, sensor data or Protobuf messages, you should consider using ReductStore as a MQTT database. It is a time series database specifically designed to store large amounts of unstructured data, optimised for IoT and edge computing.
ReductStore provides client SDKs for many programming languages to integrate it into your infrastructure. For this example, we will use the JavaScript client SDK.
Let's build a simple application to understand how to keep a history of MQTT messages using ReductStore and Node.js.