Repository navigation
NetMQ: wait for a subscriber before the first publish (slow joiner) - #106
Merged
Merged
Conversation
The publisher slept a fixed second after binding before its first send, so subscribers slower than that (as on CI runners) missed the first messages. Use an XPUB socket, which receives subscriptions: still give subscribers at least the same second to join, and if none has subscribed to the topic by then, keep waiting for one, up to 5 seconds. Run the NetMQ tests in the CI broker step again. Fixes #102 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #102.
Cause
ZeroMQ publisher sockets drop messages sent before a subscriber has connected (the "slow joiner").
MessagePublishercreates its socket on the first publish and then slept a fixed 1 second "to wait for subscribers". Any subscriber slower than that lost the first messages. That kept happening on CI runners, which is why the NetMQ tests had to stay out of the CI broker step.Fix
XPublisherSocket, which receives subscribe messages, so it can tell when a subscriber for its topic has actually joined.Trade-off: a publisher with no subscriber at all now waits up to 5 seconds on its first publish, instead of 1. This happens once per publisher.
Testing (all local, no broker needed)
FirstMessageReachesASubscriberThatConnectsLate. The subscriber joins 1.5 seconds after the publisher starts.🤖 Generated with Claude Code