Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribe_cb preempted by mqtt_publish? #1

Open
hexagon5un opened this issue Sep 20, 2016 · 1 comment
Open

Subscribe_cb preempted by mqtt_publish? #1

hexagon5un opened this issue Sep 20, 2016 · 1 comment

Comments

@hexagon5un
Copy link

Hiya Tuan,

Awesome work!

I was playing with your demo code, all just fine. Then I noticed that calling a publish shortly after a subscribe seems to prevent a publish from within the subscribe callback from being run.

In your demo, the subscribe command triggers the subscribe callback which then runs code that publishes "abcde" to the test channel. When I add a publish line:

void connected_cb(void *self, void *params)
{
    mqtt_client *client = (mqtt_client *)self;
    mqtt_subscribe(client, "esp32_test", 0);
    mqtt_publish(client, "esp32_test", "howdy!", 6, 0, 0); 
}

the "abcde" as well as the debug messages from the subscribe callback never get run.

However, when I send messages to the subscribed channel, the data comes in and gets processed like it should. So it looks like it's subscribed properly, but the feedback (pub and log messages) just don't work.

I would start to dig into the timings of all this, but I think that you are much more familiar with the code at this point. :)

@tuanpmt
Copy link
Owner

tuanpmt commented Sep 21, 2016

The reason is sending thread write multiple message in the same time, and receiving thread only know last message (with msg_pending_id and msg_pending_type). I'm thinking simple way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants