Skip to content

Errors in PubSub.cpp #494

Answered by jmklix
Ivan3141 asked this question in Q&A
Nov 12, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Did you make sure to remove the locks in the sample:

        {
            std::unique_lock<std::mutex> receivedLock(receiveMutex);
            receiveSignal.wait(receivedLock, [&] { return receivedCount >= messageCount; });
        }

The PubSub sample only prints the messages when it receives them back from the IoT core. Since you don't subscribe to the topic you won't receive anything. And if you don't remove the lock mentioned above then the program will send one message then wait to receive one before continuing and sending the second publish

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@jmklix
Comment options

Answer selected by jmklix
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants