[zeromq-dev] PUB/SUB missed initial message even using monitor events (possibly just #2267, but not sure)

Jason Heeris jason.heeris at gmail.com
Tue Feb 7 02:10:43 CET 2023

On Mon, 6 Feb 2023 at 23:26, Bill Torpey <wallstprog at gmail.com> wrote:
> If you have pub sockets connecting to subs, then probably yes. [...] When a
> sub connects to a pub, the sub’s subscriptions are sent along with the
> connection request.  So when the connection is made, the pub already has the
> sub’s subscriptions.
> When a pub connects to a sub, there is an additional exchange following the
> connect for the sub to send its subscription information to the pub, which
> takes additional time and in any event is asynchronous to the publishing of
> messages.

I think there's a terminology issue here that's adding to my confusion. When you
say "pub sockets connecting to subs" do you mean "connecting" in the ZeroMQ API
sense of connect vs. bind? Or do you mean in the less formal sense of
ordered-in-time? Because my pub sockets always bind, and my sub sockets always
connect. But in these tests, the "sub" process makes its Socket::connect() call
earlier in time than the "pub" process makes its Socket::bind() call, to the
same endpoint.

> Also, it’s not a great idea to use the socket monitor for “command and
> control”

I'm only doing it to debug the tests. In my application code, I either use
dealer sockets to synchronise as needed, or the subscriber doesn't care.


More information about the zeromq-dev mailing list