debian - Paho-mqtt.client can connect to digital-ocean mqtt server but cannot subscribe -


please me this. have spent 2 days on no success.

i using paho-mqtt python client example. have hivemq mqtt server on digitalocean debian server. client example code in python can connect , subscribe digitalocean server if run on laptop or on linux debian machine. but. here but. when run client on digitalocean server (where hivemq mqtt server is) can connect , not subscribe! used both localhost , server ip, still no luck.

however same client code running on digitalocean server (along hivemq mqtt server) can connect , subscribe external servers such m2m.eclipse.org.

how know doesn't subscribe connects? well, returns rc:0 on connect callback, not return on subscribe callback. (it should return 'subscribe: 1' etc)

in conclusion: clinet can connect cannot subscribe when running on same machine server.

the problem seems sub.py example (from here: http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.python.git/tree/examples/sub.py) seems incorrect. not execute subscribe in on_connect callback directly after connecting. understanding is, connect() method not block connack.

you verify if sleep e.g. second after connecting.

so call subscribe() in on_connect callback.

the official paho page shows how correctly, see getting started page here: https://eclipse.org/paho/clients/python/

the reason why wrong code works mosquitto , not hivemq is, mosquitto single threaded , hivemq async , multi-threaded. connect , subscribe can executed in parallel, want sequential behaviour likely, why must use on_connect() callback.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -