Paho connection/disconnection freezing [message #1841195] |
Thu, 06 May 2021 03:50  |
Eclipse User |
|
|
|
Hi everyone!
I am working on python mqtt paho v1.5.1 for a connected device.
I connect the device to the broker with connect_async and start_loop.
When the machine does not succeed to publish the message ( mostly due to a connection problem ).
I disconnect the mqtt to the broker and restart a connection like I did the first time.
However, when the device is installed in some specific places where the internet connection is quite bad, it happens that the thread managing the connection-disconnection freezes and does not respond anymore. It is no more possible to publish mqtt message neither.
In this situation, the only possibility is to restart a thread managing mqtt problems but it is not a long term solution because at some point, it reaches the limit of thread on the device.
I have also seen that connect_async and start_loop would manage by itself connection-disconnection to the broker. so I wonder if what I am doing is the right way to do it?
Is it correct to disconnect-reconnect with connect_async and start_loop when we lost connection and we are no more able to publish or is it unadvised to do it manually and start_loop should manage it by its own?
Thank you in advance
Best regards
|
|
|
|
|
Re: Paho connection/disconnection freezing [message #1841211 is a reply to message #1841206] |
Thu, 06 May 2021 10:57  |
Eclipse User |
|
|
|
Thank you very much.
In the on_disconnect, we have a stop_loop() like in the tutorial you gave but, as you said, the keepalive could give the loop alive during enough time for the thread to keep running.
Indeed, I had the feeling that paho would be able to manage by its own the connection-disconnection but I wanted another advice.
Thank you again!
|
|
|
Powered by
FUDForum. Page generated in 0.06040 seconds