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

Publisher message is lost if sent just after bind #197

Open
enrico-samknows opened this issue Jun 30, 2022 · 2 comments
Open

Publisher message is lost if sent just after bind #197

enrico-samknows opened this issue Jun 30, 2022 · 2 comments

Comments

@enrico-samknows
Copy link

Hi, I'm trying your library and I see a strange issue.
If I do this:

auto socket = std::string("ipc://test");
publisher_.bind(socket);
auto sent = publisher_.send(boost::asio::buffer(topic + " " + payload));

the message is never received by the subscriber.

If I add a

std::this_thread::sleep_for(std::chrono::seconds(1));

after .bind(), it works.
Why is that? How can I wait for the bind to be over before sending the message, without relying on an hardcoded time delay?
Is there an .async_wait of some kind?

Thanks.

@aboseley
Copy link

aboseley commented Jul 3, 2022

I think your seeing the slow-joiner syndrome, which is not unique to azmq, but a characteristic of the pub/sub pattern.

This is discussed a bit in the guide here
https://zguide.zeromq.org/docs/chapter5/#Representing-State-as-Key-Value-Pairs

The azmq unit test injects a similar delay:

TEST_CASE( "Pub/Sub", "[socket]" ) {

@enrico-samknows
Copy link
Author

Thanks, I studied the underlying syscalls with strace and I realised the client needs to subscribe before getting data. It makes sense.
Do you think 200ms is a 100% safe delay? Or should I wait 1000ms, as in the example?

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