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

issue CELERY and mqtt

Open mexekanez opened this issue 6 years ago • 5 comments

Yes I can confirm that mqtt publish does not works on celery beat.

@shared_task
def time_sched():

    print("send.....")
    
    res = mqtt.client.publish('clients/c/0000000016ab8294', json.dumps({"celery":"ok"}), qos=2)
    res.wait_for_publish()
    

@celery.on_after_configure.connect
def setup_periodic_tasks(sender, **kwargs):

    sender.add_periodic_task(5.0, time_sched.s())

this task will halt forever.

if we will use without res.wait_for_publish(), you will see that is published in logger but nothing came in to channel.

mexekanez avatar Jun 26 '19 14:06 mexekanez

but when I run it without celery just like:

@manager.command
def mqtt_test():

    
    while True:
        sleep(1)
        res = mqtt.client.publish('clients/c/0000000016ab8294', json.dumps({"celery":"ok"}), qos=2)
        res.wait_for_publish()

No issues here

mexekanez avatar Jun 26 '19 14:06 mexekanez

this is also related current issue: https://stackoverflow.com/questions/55864502/mqtt-message-not-getting-published-from-celery-beat-task

mexekanez avatar Jun 26 '19 15:06 mexekanez

any news? have the same problem

maei1337 avatar Nov 03 '19 15:11 maei1337

Hello,

I experience the same issue and this bug is open for 4 years now. What is the status?

Yours sincerely,

Quirin

quirinhamp avatar Jun 19 '23 07:06 quirinhamp

Unfortunately without additional information it's difficult to investigate; it would be useful if someone could provide an example (e.g. docker-compose with everything necessary to duplicate the issue) or full code (showing how the connection is established) and logs (the easier you can make it for us to replicate/track the issue the more likely it is that we will be able to resolve it).

MattBrittan avatar Dec 24 '23 01:12 MattBrittan

I'm going to close this due to lack of activity/reproducability. Please feel free to reopen if you are able to provide a way for us to duplicate the issue (or debug logs etc).

MattBrittan avatar Jul 17 '24 22:07 MattBrittan