How messageArrived() callback and MQTTYield() works in paho-mqtt-embedded-c ?

27 views
Skip to first unread message

Maunik Patel

unread,
Apr 10, 2018, 5:21:20 AM4/10/18
to MQTT
Hello all.

I am using paho-mqtt-embedded-c Library on my beaglebone black.
All I want to do is to make 1 publisher application and 2 or more subscriber applications, which subscribes to the same topic, to which publisher is publishing.
The broker I am using is a cloud Service named 'cloudMQTT'

If I publish to the topic with retained flag set, and then run subscriber, it receives the message (it is actually a retained message, which broker sends to clients when new network connection with same topic subscription is connected).

If I publish with retained flag reset, then run subscriber, it can’t receive the message.
Even if I run subscriber 1st and then publish with retained flag set/reset, my subscriber can’t receive the message.
What should be the fix for this ?

- What if I want to keep running my subscriber to get each published message ?
I think calling MQTTYield() in a while(1) loop should work
But it actually doesn’t, for me at least.

If some one can answer my below questions, it will help me a lot.
- How and when the MQTTSubscribe() calls messageArrived() callback function?
- When messageArrived() is invoked and till when it runs?
- How MQTTYield() works exactly?

Reply all
Reply to author
Forward
0 new messages