paho.mqtt.python icon indicating copy to clipboard operation
paho.mqtt.python copied to clipboard

publish blocks entire program

Open mhechthz opened this issue 5 years ago • 7 comments

I have a really difficult problem.

I'm using paho-mqtt inside python 3.7 on mosquitto broker at an ubuntu 18.03 system. The program is a bridge between two brokers (which could surely be solved via mosquitto directly, but I did it this way).

One special defined publish command of one client object irregularely hangs the entire program, i.e. starts but doesn't come back. Even timer events are blocked. The only solution is to kill the program from outside. The command itself is obviously ok, since I can send a hundred of publishes without problem. Also try-catch doesn't help, since the pogram hangs. No other publish command of both client object in the program shows this behaviour.

Is there any chance to analyze what happens?

EDIT: I added a threading.Semaphore() on friday - during weekend all seemed to be stable. Migth this be a hint? EDIT2: Also with semaphore the call to publish blocks / hangs the program.

mhechthz avatar Dec 11 '20 08:12 mhechthz

I have similar issue. I use loop_start and on_message callback. The callback publishes new messages on different topic. I also have a "while True" loop, which publishes something from time to time. It seems that when these two try to publish at the same time, the publish metod hangs and doesn't return.

karolszklarski avatar Dec 16 '20 22:12 karolszklarski

Could you both take a look at the 1.6.x branch? I've made improvements around the locking which may help here.

ralight avatar Jul 22 '21 01:07 ralight

hi @ralight when 1.6.x release?

lytasky avatar Aug 24 '21 10:08 lytasky

I'm planning a release around the end of September.

ralight avatar Aug 24 '21 10:08 ralight

I had a similar problem where the client.publish was taking way too long and switching to the 1.6.x branch fixed the issue

dplaks-del avatar Sep 09 '21 13:09 dplaks-del

I'm getting the same thing.

David-OConnor avatar Oct 23 '23 23:10 David-OConnor

I'll need to information on how to reproduce this bug, as I never had publish() which hang the program in my usage.

#710 could be the same issue: a publish which network is down could result in publish being lost. #710 is merged but not yet released.

PierreF avatar Jan 07 '24 11:01 PierreF