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

Pieter Hintjens ph at imatix.com
Wed Nov 13 12:53:08 CET 2013


Indeed, PUSH and DEALER sockets do not accept messages until a
connection is established. The formal specification of these sockets
is here: http://rfc.zeromq.org/spec:30

-Pieter

On Wed, Nov 13, 2013 at 12:44 PM, Panu Wetterstrand
<panu.wetterstrand at iki.fi> wrote:
> Hi,
>
> 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 zmq.
>
> 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.bind("tcp://*:12345");
>             pullSocket.connect("tcp://localhost:12345");
>
>             pushSocket.send("bytes", ZMQ.NOBLOCK);
>             Assert.assertEquals(pullSocket.recvStr(), "bytes");
>
>         } finally {
>             context.term();
>         }
>     }
>
>
> 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.
> --
> Panu
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



-- 
-
Pieter Hintjens
CEO of iMatix.com
Founder of ZeroMQ community
blog: http://hintjens.com



More information about the zeromq-dev mailing list