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

1st published message does not get received by subscribe callback #73

Closed
cbumgard opened this issue Jan 17, 2017 · 2 comments
Closed

1st published message does not get received by subscribe callback #73

cbumgard opened this issue Jan 17, 2017 · 2 comments

Comments

@cbumgard
Copy link

Hi there, when I run the subscribe_publish_sample with a single publish, the subscribe callback never runs. The subscribe callback gets invoked x - 1 times, where x is set via the command-line and is represented as publishCount in the code. However the CloudWatch log shows the correct number of x published messages, so it appears to just not be sending back from the broker to the local client for the first published message.

As I'm adapting this sample for my own use, and would like to understand if this is a bug or expected behavior.

Here is example output:

x=1 does not show the subscribe callback:

$ ./subscribe_publish_sample -x 1
...
Subscribing...
-->sleep
Publish done

Shows (x - 1) messages in subscribe callback:

$ ./subscribe_publish_sample -x 3
...
Subscribing...
-->sleep
Subscribe callback
sdkTest/sub	hello from SDK QOS1 : 1 
Subscribe callback
sdkTest/sub	hello from SDK QOS0 : 0 
-->sleep
Publish done
@chaurah
Copy link
Contributor

chaurah commented Jan 19, 2017

Hi @cbumgard,
Its a bug in the sample. The loop that is doing publish exits here without waiting for the last set of messages to be received. I have made a note of this and will improve the sample for the next release. Until then, you should be able to resolve it by simply adding an aws_iot_mqtt_yield after the loop ends to catch any messages that have not been received yet.

Thank you for pointing this out. Please let us know if you have further questions.

Rahul

@cbumgard
Copy link
Author

Understood, thank you @chaurah

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