[zeromq-dev] Multiple connects with a ZMQ_REQ socket appears not to work

Mark e2c at papa.emu.st
Fri Feb 23 05:57:57 CET 2018

Hi all.

According to http://api.zeromq.org/4-2:zmq-socket with a ZMQ_REQ
socket I can connect to multiple endpoints and the semantics of
zmq_send() are:

	"Each request sent is round-robined among all services, and
	each reply received is matched with the last issued request.

	If no services are available, then any send operation on the
	socket shall block until at least one service becomes
	available. The REQ socket shall not discard messages."

IOWs the message should get to one of the connected endpoints

But I'm not seeing that behavior. Rather, the message never arrives at
any of the available endpoints.

To demonstrate this I hacked up the hello world examples such that the
client connects to two endpoints: the first nominates a port that
nothing is listening on and the second nominates a port that the
server is listening on. What I'm seeing is that the message exchange
never occurs.

I have attached both programs as they are minorly different from the
examples on the zmq website.

If I swap the connect order in the client such that the "up" server
comes first, then the message exchange works. After further testing I
deduce that attempting to exchange with second and subsequent connect
endpoints are the problem.

>From a system-call trace I can see the connection being established
and going thru at least some of the 0MQ setup exchange, but the
application messsage never gets sent. My suspicion is that the 0MQ
setup isn't completing for some reason.

I have tried this on macOS, FreeBSD and a recent Debian with the same
results. I have also tried it with zmq versions 4.2.1 and 4.2.3 - also
with the same results.

Am I mis-reading the ZMQ_REQ socket semantics or have I coded up the
client wrongly?

What I'm trying to achieve is running the same REQ/REP server on
multiple systems for redundancy and use 0MQ to automatically find a
working server on behalf of the client.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: s.c
Type: text/x-csrc
Size: 610 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180223/b8863bec/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: c.c
Type: text/x-csrc
Size: 894 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180223/b8863bec/attachment-0001.c>

More information about the zeromq-dev mailing list