Configuring the MQTT server

This script allows you to subscribe to an MQTT topic, receive messages and store them in a SQLite database. The steps to configure and execute it correctly are described below.

1. Configuration of the configuration file

Before running the script, a configuration file in .ini format must be created. This file contains the necessary parameters for the connection to the MQTT broker, the database and the log configuration. An example of a configuration file is as follows:

[DEFAULT]

;;topic
topic = testtopic/#

;; connection
host = test.mosquitto.org
port = 1883
;; protocol supports:  tcp, websockets, unix
; protocol = websockets 
; user = ro
; password = readonly
; ssl = 0
; trust_ssl = 1

;; Database
dblocation = /opt/pandora/pandora_iot_server/db
dbname = pandora_iot.db
; data_cleaning_interval = 300  
; data_cleaning_period = 86400  

;; Logs
log_name = pandora_iot.log   
log_location = /var/log/pandora/
; log_level = debug              
; max_log_bytes = 50_000_000         
; log_rotation_count = 3
Key parameters:
2. Start the service.

The service can be launched with the following command :

systemctl start pandora_iot_server

To stop receiving and storing messages, you can pause the service with :

systemctl stop pandora_iot_server

The service must be restarted with each configuration change for it to take effect:

systemctl restart pandora_iot_server
3. Start server from console

In version 783, the following token was introduced to enable the IOT server.

To get there, we need to go to the Management > Settings > System Settings > General Setup

Then enable the Enable IOT server field and finally press Update.

image.png


Revision #5
Created 10 April 2025 10:52:55 by alejandro.sanchez
Updated 30 October 2025 10:41:43