[zeromq-dev] ZMQ in ocaml rep socket does not recv all

Kenneth Adam Miller kennethadammiller at gmail.com
Tue Nov 25 17:27:59 CET 2014

I think I figured out what the issue was, I have multiple unit tests, and
two tests were sharing the same zmq context. So once I added a call to
destroy at the end of the first one, the first test started missing

I think that zmq context destruction is causing some messages to be lost.
How do I make sure that the messages get sent before the context is

On Tue, Nov 25, 2014 at 3:10 AM, Kenneth Adam Miller <
kennethadammiller at gmail.com> wrote:

> In the process of debugging it, I went back to the request socket and
> commented out the portion where the reply socket is given an additional
> request. So now I have:
> ==========req socket
> send ""
> recv request
> //... computes result
> //send result !!! commented out, never occurs
> ==========rep socket
> recv // ""
> send reply //(that is a serialized RPC request)
> recv // returns ""    <- why does this occur?
> Could this be anything to do with the request socket being closed before
> all of the data is sent? Or the context destroyed prematurely? I thought
> the linger period default was -1... I don't know to diagnose why the rep
> socket can recv, in both cases where the rep socket's second send is
> un-commented and when it is commented.
> On Mon, Nov 24, 2014 at 5:58 PM, Kenneth Adam Miller <
> kennethadammiller at gmail.com> wrote:
>> In ocaml I am using ZMQ and piqi to serialize data structures to strings
>> and ZMQ to send them around. I'm having a problem where I'm using a tcp REQ
>> socket to request work (initially) and a TCP reply socket to send the
>> results back. In my unit tests, I can see that the test subvect (worker)
>> correctly receives a work request, correctly computes a result, and then
>> sends that back to a psuedo (work broker). Basically it goes like this, 1 &
>> 2 are concurrent:
>> 1) worker sends "" over req to signify that it is ready to receive
>> requests. This first request string is empty, but from here on out,
>> subsequent requests contain the result of work computation
>> subsequently, the worker receives some reply from the psuedo broker; some
>> call that maps to a function that is deserialized via piqi parse calls.
>> (This part is what I was saying is correct in my test) It correctly
>> computes what is desired.
>> worker's sending of computed result back out over req string is the
>> result of computation and signifies to broker that it is ready for more.
>> 2) psuedo broker recvs the empty string, and routes a piqi serialized RPC
>> request to the worker.
>> psuedo broker should simply receive the computation result. *Instead it
>> receives an empty string;* I've checked in the worker code, and it's
>> *not sending an empty string.
>> Why?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20141125/a1b1ecd5/attachment.htm>

More information about the zeromq-dev mailing list