Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Losing subscriptions (RPi Python Paho)(Stops receiving data from subscription at random)
Losing subscriptions (RPi Python Paho) [message #1860336] Sun, 30 July 2023 08:01 Go to next message
Marc Engrie is currently offline Marc EngrieFriend
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.
Re: Losing subscriptions (RPi Python Paho) [message #1860341 is a reply to message #1860336] Mon, 31 July 2023 10:03 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 83
Registered: March 2013
Member
Have you set clean_session to False when constructing the client?

If you don't the broker will default to losing the subscriptions when the connection is lost. I know you said that you didn't think the connection was lost, but maybe the broker thinks it has been?

Re: Losing subscriptions (RPi Python Paho) [message #1860347 is a reply to message #1860341] Mon, 31 July 2023 17:28 Go to previous messageGo to next message
Marc Engrie is currently offline Marc EngrieFriend
Messages: 3
Registered: July 2023
Junior Member
Yes, clean_session is set to False
Re: Losing subscriptions (RPi Python Paho) [message #1860349 is a reply to message #1860341] Mon, 31 July 2023 17:31 Go to previous message
Marc Engrie is currently offline Marc EngrieFriend
Messages: 3
Registered: July 2023
Junior Member
I would love to try with QoS different from 0 but that seems impossible with this package. Or am I wrong?
Previous Topic:How to handle exception in loop thread
Next Topic:How to include MQTT5 into jar (got class not found exception)
Goto Forum:
  


Current Time: Fri May 03 04:53:16 GMT 2024

Powered by FUDForum. Page generated in 0.03548 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top