[zeromq-dev] Dropped messages when not sleeping, using 0MQ 2.1.x
James Cipar
jcipar at cmu.edu
Sun Sep 18 18:21:51 CEST 2011
Each process is single threaded. The pushers are not calling zmq_term because they continue running and listening for more commands after sending their data. I want to close the socket, but keep the 0MQ context running.
In case it isn't clear: I forgot to mention that I'm using the C++ binding for 0MQ.
On Sep 18, 2011, at 12:07 PM, Wolfgang Richter wrote:
> Also, perhaps you need to use zmq_term as stated:
>
> http://zguide.zeromq.org/page:all#-MQ
>
> Just another idea.
>
> --
> Wolf
>
> On Sun, Sep 18, 2011 at 12:05 PM, Wolfgang Richter <wolf at cs.cmu.edu> wrote:
> You aren't using threads are you? You mentioned it was a large system.
>
> Make sure you don't pass sockets around between threads.
>
> --
> Wolf
>
>
> On Sun, Sep 18, 2011 at 11:52 AM, James Cipar <jcipar at cmu.edu> wrote:
> Hi,
> I'm using PUSH/PULL sockets in a system where I have many pushers connected to a single puller. The pushers connect, send a few hundred messages, then send a special "end" message and close the socket. The puller counts how many "end" messages it has received, and once it has enough, it quits.
>
> I'm having a problem where the "end" messages are occasionally dropped (and perhaps other messages as well). However, if I put a "sleep(1)" immediately before the "close()" call, it works as expected, and all messages arrive. I am using 0MQ 2.1.9 (and also tried on 2.1.7) on Debian Squeeze.. I thought that the sleep before close was no longer necessary on 2.1.x. It also seems dependent on the data set that the pushers are sending. Sometimes it works without the sleep, and sometimes it does not. Strangely, it is the *smaller* data set that causes problems. I'd like to avoid the sleep call, because I want the pushers to go on to other work as soon as they finish sending data.
>
> Unfortunately, I'm having trouble constructing a minimal test case. As it's a large system, and the occurrence of the error seems dependent on the data being sent. Here is the relevant code for the error:
>
> int linger;
> size_t l_size = sizeof(linger);
> sender.getsockopt(ZMQ_LINGER, (void *)(&linger), &l_size);
> assert(l_size == sizeof(linger));
> cout <<"closing sender, messages will linger for "<<linger<<" milliseconds\n";
> sleep(1);
> sender.close();
>
> If that "sleep" call is commented out, it will drop messages; with the sleep, it will not. The "cout" is printing -1, as expected.
>
> Is there any reason to expect this system to be dropping messages?
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list