[zeromq-dev] ZMQ dealer not receiving message from ZMQ router with ZMQ_FD

Kah-Chan Low kahchanlow at yahoo.com
Wed Oct 31 04:03:37 CET 2012


Before detailing my problem here are some of the particulars of my current project:

1. I am using C++ on Linux red hat release 5 (or 6)

2. I have to use select() instead of zmq_poll()
3. I am using ZMQ dealers as clients connected to ZMQ routers in a many-to-many configuration.
4. Messages may be sent in arbitrary sequences which may or may not require responses (that's why I can't use REP and REQ)

5. Each node is running in its own thread.
6. Each node has multiple ZMQ & regular sockets.
7. Each thread is event driven: select() is called in an endless loop.

I have read about the caveats of using ZMQ_FD so once an event is triggered, I do use ZMQ_EVENTS to test for ZMQ_POLLIN before calling zmq_recv()
I also make use that I read all messages off a socket once a read event is triggered.

I am running into problem when this happens:

1. At node A: ZMQ dealer sends a message to each ZMQ router at another node that it is connected to.
2. On each connected node, the ZMQ router receives the message and immediately sends a reply back to the dealer.
3(!) At node A: the read event for the ZMQ dealer was never triggered, even if the socket has not received any prior message after its creation.  The thread never wakes up from select()


I have verified that the messages have been received by timing out on select() and forcing non-blocking reads on the ZMQ dealer.
There's no problem if I use zmq_poll().

I have read that some people had similar problems and they were advised to keep reading until EAGAIN before calling select(). I can't do that since the ZMQ dealer is only one of a number of sockets owned by the thread and any one of them may receive a message at any time.

What should I do?  Have I done anything wrong?  What should I watch out for?

Thanks!!
KC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121030/86ae9808/attachment.htm>


More information about the zeromq-dev mailing list