Losing subscriptions (RPi Python Paho) [message #1860336] |
Sun, 30 July 2023 08:01 |
Marc Engrie Messages: 3 Registered: July 2023 |
Junior Member |
|
|
Struggling with a problem for over 2 months now, debugging and changing code to overcome my problem but so far, without succes. So that is why I post it here
Setting: I am running a Python (3.9.2) application on a RPi 4B 2GB running Debian GNU/Linux 11 (bullseye) Linux aarch64 V6.1.21-v8+ where I use the the package paho-mqtt V1.6.1.
My mosquitto server runs on a Windows PC.
I have 6 devices publishing every (60 sec + random(60 sec)) some data. Graphing this data with Grafana+Telegraf (subscribing to topics) works like a charm. Not data lost.
My python app, connects and subscribes to these topics using eg : mqtt_subscribe(co2_topicbase + "/#") to capture all (at the moment 5) CO2 sensors sending data. I use # as co2 sensors might come and go ans so I do not need to change application at every change in sensors.
(NB: other sensor is a waterflow sensor but setup is the same).
So I config paho client is this way: config instance with ID, login, pw ; setting will_set, setting on_ ... callbacks, loop_start(), connect.
On_connect, I subscribe to topics. On_message I figure out which topic came in and store the data of payload in dictionary. I set a flag, data came in.
I have a inifinte while loop where I display some data and when flag is true, handle the data which include also being publish on the MQQT server but on another topic.
This will work for 1 hour, 5 hours, 12 hours untill suddenly, the app stops receiving data. There is no disconnection from the MQTT server as I see no notification of disconnection in my log from on_disconnect.
My last program change was to monitor the time between 2 data arrivals. When over 5 minutes, I do a reconnect to the server But even this will not cure the problem. Also I do a reboot every midnight (to clear memory in case of any memory leak) but also this brings no improvement.
What am I doing wrong? What could be the cause of this 'behaviour'? Are there any settings I need to do?
Any suggestion more than welcome.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03548 seconds