.net - ZeroMQ PUSH/PULL and lost message -


i'm making use of zeromq .net , got stuck trying fix weird issue. i've got socket of type push , 1 of type pull on tcp. when client disconnects, server still able to send message (note no flags passed socket.send method) gets lots before starting block , waiting client reconnect , delivering messages try send afterwards.

how can avoid losing message (or in worst case test if client connected , if not send dummy message can afford losing)?

thanks in advance!

edit: further testing reveals if wait 1 second after sending first message after disconnection client, second 1 block, if don't wait @ can send many messages want , they'll lost. that's quite confusing...

the zeromq documentation notes problem push/pull setups , suggests following pattern: addition of rep/req setup provide node coordination when you're expecting fixed number of subscribers. however, if not able know number of subscribers in advance, should consider changing protocol more resilient these conditions.

synchronized publisher in c (from zguide)

// //  synchronized publisher // #include "zhelpers.h"  //  we wait for 10 subscribers #define subscribers_expected  10  int main (void)  {     s_version_assert (2, 1);     void *context = zmq_init (1);      //  socket to talk to clients     void *publisher = zmq_socket (context, zmq_pub);     zmq_bind (publisher, "tcp://*:5561");      //  socket to receive signals     void *syncservice = zmq_socket (context, zmq_rep);     zmq_bind (syncservice, "tcp://*:5562");      //  get synchronization from subscribers     int subscribers = 0;     while (subscribers < subscribers_expected) {         //  - wait for synchronization request         char *string = s_recv (syncservice);         free (string);         //  - send synchronization reply         s_send (syncservice, "");         subscribers++;     }     //  now broadcast exactly 1m updates followed by end     int update_nbr;     for (update_nbr = 0; update_nbr < 1000000; update_nbr++)         s_send (publisher, "rhubarb");      s_send (publisher, "end");      zmq_close (publisher);     zmq_close (syncservice);     zmq_term (context);     return 0; } 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -