I’m trying to set up “inverted” PUB/SUB with ZeroMQ.
Meaning that subscribing (SUB) sockets belong to several long-living servers, doing zmq_bind(); and publishing (PUB) socket is a short-lived client and does zmq_connect().
I use a single ipc:// socket.
I expect that a message from the publisher will reach each of subscribers.
The problem: Only one of subscriber processes ever receives messages. If that process dies, publisher gets stuck in zmq_term().
Is this mode of operations supported by zmq? If yes, then what am I doing wrong? If no, then how to implement what I need?
Minimal example with some additional details (in Lua, but this should not matter): https://gist.github.com/938429
You can’t bind multiple sockets to one
ipc://address (we are talking about Unix Domain Socket here ipc:///tmp/test.ipc == file /tmp/test.ipc).What you can do is bind each SUB socket to a different ipc:// address and have the publisher connect one PUB socket to each of those addresses. ZeroMQ allows one socket to bind/connect to multiple addresses.
The blocking on zmq_term() is most likely do to lingering close issue (i.e. there is a message that the PUB socket is trying to send). Take a look at the ZMQ_LINGER socket option.