[zeromq-dev] Connect and bind with PULL-PUSH sockets

Panu Wetterstrand panu.wetterstrand at iki.fi
Wed Nov 13 12:44:34 CET 2013


this is probably just error between the chair and screen, but I can't
figure out what I am doing wrong. I am under the impression that type of
the socket and whether it binds or connect is separated concern when using

But it seems that PULL and PUSH sockets do not work that independent from
connect/bind concepts. Case where PUSH connects and PULL is binded and
connection is declared before bind everything works as expected. But if
PULL socket is connected or binded before, problems start to occur.

For example this fails:

    @Test(timeOut = 5000)
    public void pushBindsBeforePullConnects() throws Exception {
        ZMQ.Context context = ZMQ.context(1);
        try (ZMQ.Socket pullSocket = context.socket(ZMQ.PULL);
                ZMQ.Socket pushSocket = context.socket(ZMQ.PUSH)) {


            pushSocket.send("bytes", ZMQ.NOBLOCK);
            Assert.assertEquals(pullSocket.recvStr(), "bytes");

        } finally {

Test will wait for message forever (or at least impractically long).
However if blocking send is used test will pass. It seems that PUSH socket
does not accept any messages before connection has been made. I would have
thought that PUSH would accept messages until HWM is reached.

Any idea what am I doing wrong?  I am using libzmq version 3.2.4 and jzmq
bindigs version 2.2.2.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131113/8cd460e7/attachment.htm>

More information about the zeromq-dev mailing list