-
Notifications
You must be signed in to change notification settings - Fork 25
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
Sending Message to Bus fails if called Too Soon #53
Comments
Merging from #54: From #52, there appears to be a condition where we can try to send things across the bus before it's fully connected. This is definitely something which can happen with ZMQ, and may be seen with something like:
Solutions could be:
This ticket may also be a duplicate of #52 if this is the actual cause. (It may not be). Many thanks to @techman83 in helping find this. |
Looking at the doco, this may actually be expected behavior!
Though there may be still a small delay after the initial message. #!/usr/bin/env perl
use feature qw(say);
use Exobrain;
my $exobrain = Exobrain->new;
my $count = 0;
while ($count < 11) {
say "Hello World $count";
$exobrain->notify("Hello World $count");
$count++;
} Which produces:
However only the following hits the log + pushover:
However it's not consistent. Sometimes it only misses the first message, sometimes it's two or three messages. Though if you put a sleep after the first message it seems happy enough. Not sure what the best solution is. The delay needs to be just long enough to allow the tcp connection to finish it's handshake. Though if we move beyond just localhost connections (something I desire), this delay could be quite unknown. |
I've been sporadically doing quite a lot of reading about this issue and pondering ways to solve it. Overall ZMQ appears to have been designed for messaging performance, so the reality is that if the messages are important they need to have acknowledgments. I think to begin with, the best idea will be to send a message to the bus and have a short wait as a exobrain->connect function as suggested. And in the long term add in received acknowledgements and timeouts. |
Submitted #57 that appears to reliably fix this on localhost. However it may require some further testing over a latent link. Though Exobrain's current design is for local connections, so this should more than satisfy the requirements. |
Had a bit of a chat with @domm regarding this issue. Setting up some sort of message acknowledgement could add a whole bunch of different things to think about, along with complications. There are ZMQ_EVENTS that we might be able to lean on, but I'm unsure how backwards compatible that is. There is probably a way to automate the connect function and use a sleep for older versions, loop for newer. I'll refresh myself and take a look next time I have some spare cycles. |
Credit to @pjf as his brain wave figured it out. Code to duplicate the issue:
Results in only "Hello World 2" making it to the notification service.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: