[zeromq-dev] problem with zmq::poll in ZMQ_REQ-ZMQ_ROUTER example

Sandeep Joshi sanjos100 at gmail.com
Mon Apr 14 17:30:06 CEST 2014


This error in zmq_poll was due to the same problem resolved today by Goswin

http://lists.zeromq.org/pipermail/zeromq-dev/2014-April/025880.html

Every client must set the identity to be unique using
zmq_setsockopt(ZMQ_IDENTITY) otherwise the ROUTER gets confused.   Once I
did that, the programs worked.

-Sandeep


On Sun, Apr 13, 2014 at 8:03 AM, Sandeep Joshi <sanjos100 at gmail.com> wrote:

>
> Hi All,
>
> I am running zmq 3.2.3 and have some difficulty getting zmq::poll to work
> with the frontend and backend sockets.
>
> I modified the lbbroker.cpp example available in the zguide to move to the
> client thread to a separate process in order to simulate the case where
> multiple client processes connect to a multi-threaded server.
>
> https://github.com/imatix/zguide/blob/master/examples/C%2B%2B/lbbroker.cpp
>
> There are now two programs
> Client : http://paste.ubuntu.com/7242473/
> Multi-threaded Server : http://paste.ubuntu.com/7242472/
>
> I deliberately added a "sleep(10") inside the worker_thread() to make it
> pause and see if more than one worker threads are ever busy.  And I changed
> the client to send multiple requests instead of just one.
>
> When I ran the server followed by multiple instances of the client from
> different terminals, I noticed that only one client's requests are
> processed.  The other clients just seem to hang forever.
>
> When I looked at "netstat", I noticed that the other clients do have TCP
> connections in ESTABLISHED state.  From tshark, I found that there is some
> initial TCP exchange for all clients but that zmq::poll only detects one
> client's requests.  The other connected clients are just ignored.
>
> The output of the server when more than one client is connected is as
> follows:
>
> The "5006" after the "hello" below is the process id of the client.
> Notice that only one client is being serviced even though more than one are
> active.
>
> sent work req worker queue=20
> Worker: 64F6-D716:hello5006
> Worker sending resp: 64F6-D716:hello5006
> Got worker resp: 8DD0-471C:queue=20
> sent work req worker queue=20
> Worker: 64F6-D716:hello5006
> Worker sending resp: 64F6-D716:hello5006
> Got worker resp: C4AA-55D1:queue=20
> sent work req worker queue=20
> Worker: 64F6-D716:hello5006
> Worker sending resp: 64F6-D716:hello5006
>
> What am I doing wrong ?
>
> thanks
> -Sandeep
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140414/3795ca0d/attachment.htm>


More information about the zeromq-dev mailing list