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

Panu Wetterstrand panu.wetterstrand at iki.fi
Wed Nov 13 13:32:25 CET 2013


Ok. I suspected something like this.

This information could be more clearly stated at ZMQ API (
http://api.zeromq.org/)? Or maybe I just did not find it. I tried to read
the socket and send pages, but they were not very clear on this matter. But
now I know and I will look also the specs next time I have a problem.

Thanks for the fast reply.



2013/11/13 Pieter Hintjens <ph at imatix.com>

> 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
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131113/80519512/attachment.html>


More information about the zeromq-dev mailing list