[zeromq-dev] Failed to use zeromq2.2 to communicate with zeromq4.0.1

舒友村 shuyoucun at bwstor.com.cn
Wed Nov 27 08:36:30 CET 2013


Hi, Pieter
     Thanks for your immediate reply...I know that there are two frame
which ROUTER would receive when  DEALER  peer send a message to ROUTER, the
first frame is identity, and the second frame is my sent content..but I
find that if the message sent from zeromq4.0.3 to zeromq2.2, two
message(there are two frame in every message) will receive in zeromq2.2
peer when I used czmq to recieve. It is different from zeromq4.0.3 to
zeromq4.0.3 and zeromq2.2 to zeromq2.2. If it is zeromq 4.0.3 to
zeromq4.0.3 there is only one message received(the message contains two
frame as your description), it is the same to zeromq2.2. I donot understand
why I receive two messages in zeromq2.2 peer. I check the code in czmq2.0.2
and I donot think it is caused by czmq2.0.2. because it is not a problem
when the two peers using the same version zeromq..
     The following is my test code.
      in zerom2.2 peer
int main (void)
{
        void *context = zmq_init(1);
        void *responder = zmq_socket (context, ZMQ_ROUTER);
        int rc = zmq_bind (responder, "tcp://*:5555");
        zmsg_t* msg;
        int i  =0;

        while (1) {
                msg = zmsg_recv(responder);
                printf("%d\n", zmsg_size(msg));
                sleep (1);          //  Do some 'work'
        }
        return 0;
}
       in zerom4.0.3 peer
int main (void)
{
    void *context = zmq_init (1);
    void *responder = zmq_socket (context, ZMQ_DEALER);
    int rc = zmq_connect (responder, "tcp://10.10.19.156:5555");
    assert (rc == 0);

    zmsg_t *msg = zmsg_new ();
    assert (msg);
    zframe_t *frame = zframe_new ("Hello", 6);
    assert (frame);
    zmsg_push (msg, frame);
    rc = zmsg_send(&msg, responder);
    sleep(10);
    return 0;
}

     Thanks..I want to know why the count of receving message is different
when the two peers installed different zeromq version.


On Tue, Nov 26, 2013 at 7:20 PM, Pieter Hintjens <ph at imatix.com> wrote:

> When a DEALER sends a message with one frame to a ROUTER, the ROUTER
> will deliver two frames; the identity, then the message. This is the
> same on 2.2 and 3.2 and 4.0.
>
> Your test code sends "Hello" without a training null byte and then
> tries to print the string. It also tries to print the identity frame
> as a string. Both these will give bogus results. The identity frame
> always starts with binary zero, so looks empty when you print as a
> string.
>
> -Pieter
>
> On Tue, Nov 26, 2013 at 10:41 AM, 舒友村 <shuyoucun at bwstor.com.cn> wrote:
> > Hi Pieter,
> >       I do some tests about communication in different zeromq version. I
> > found that zeromq2.2 peer received the content of message from
> zeromq4.0.3
> > peer is different from that received it from zeromq2.2 peer when the same
> > message is sent. Just like the following.
> >       In zeromq4.0.3 peer(client).
> >     int main (void)
> > {
> >     void *context = zmq_init (1);
> >     void *responder = zmq_socket (context, ZMQ_DEALER);
> >     int rc = zmq_connect (responder, "tcp://10.10.37.117:5555");
> >     assert (rc == 0);
> >     zmq_send(responder, "hello", 5, 0);
> >     sleep(10);
> >     return 0;
> > }
> >   In zeromq2.2 peer(server).
> >  int main (void)
> > {
> >         void *context = zmq_init(1);
> >         void *responder = zmq_socket (context, ZMQ_ROUTER);
> >         int rc = zmq_bind (responder, "tcp://*:5555");
> >
> >         while (1) {
> >                 zmq_msg_t msg;
> >                 zmq_msg_init(&msg);
> >                 zmq_recv (responder, &msg, 0);
> >                 printf ("%s\n", zmq_msg_data(&msg));
> >                 sleep (1);
> >         }
> >         return 0;
> > }
> >
> > I found that it would receive 3 empty message in zeromq2.2 peer before
> > receiving the "hello",
> > but if the peer is installed zeromq4.0.3 ,just like following
> >  int main (void)
> > {
> >         void *context = zmq_init(1);
> >         void *responder = zmq_socket (context, ZMQ_ROUTER);
> >         int rc = zmq_bind (responder, "tcp://*:5555");
> >         assert (rc == 0);
> >
> >         while (1) {
> >                 char buffer[10];
> >                 zmq_recv(responder, buffer, 10, 0);
> >                 printf ("%s\n", buffer);
> >                 sleep (1);          //  Do some 'work'
> >         }
> > }
> > there is only 1 empty message before receiving "hello". and if it is
> between
> > zeromq2.2 and zeromq2.2. the result is the same to between zerom4.0.3 and
> > zeromq4.0.3....
> > I want to know if it is expected to this result? if like this, I think my
> > updating one peer from zeromq2.2 to zeromq4.0.3 and the other peer
> retains
> > zerom2.2, when zeromq4.0.3 send message to zerom2.2 peer, my application
> > cannot explain the message. Or any problem my usage? thanks...
> >
> >
> > On Sun, Nov 24, 2013 at 7:37 PM, Pieter Hintjens <ph at imatix.com> wrote:
> >>
> >> Hi,
> >>
> >> Sorry for the slow response.
> >>
> >> So there are some problems with your test case.
> >>
> >> - zmq_send in ZMQ/2.x sends a zmq_msg_t structure, not a memory buffer
> >> - the ROUTER socket will return an identity blob as first part; you
> >> cannot print this as a string
> >>
> >> When I fix these problems and run the test case, it crashes as follows:
> >>
> >> Assertion failed: buffer_size == header_size (stream_engine.cpp:484)
> >>
> >> Which is issue 569, https://zeromq.jira.com/browse/LIBZMQ-569.
> >>
> >> I'll cut a new stable release with this fix. In the mean time you can
> >> build the stable version from https://github.com/zeromq/zeromq4-x
> >>
> >> -Pieter
> >>
> >> On Fri, Nov 22, 2013 at 4:05 PM, 舒友村 <shuyoucun at bwstor.com.cn> wrote:
> >> > Hi , The following is my test case.
> >> > The peer installed zeromq2.2:
> >> > int main (void)
> >> > {
> >> >     //  Socket to talk to clients
> >> >     void *context = zmq_init (1);
> >> >     void *responder = zmq_socket (context, ZMQ_DEALER);
> >> >     int rc = zmq_connect (responder, "tcp://10.10.19.154:5555");
> >> >     assert (rc == 0);
> >> >
> >> >     char buffer [10];
> >> >     zmq_send(responder, "hello", 0);
> >> >     sleep(10);
> >> >     return 0;
> >> > }
> >> >
> >> > The peer installed zeromq4.0.1
> >> > int main (void)
> >> > {
> >> > void *context = zmq_init(1);
> >> > void *responder = zmq_socket (context, ZMQ_ROUTER);
> >> > int rc = zmq_bind (responder, "tcp://*:5555");
> >> > assert (rc == 0);
> >> >
> >> > while (1) {
> >> > char buffer [10];
> >> > memset(buffer, 0, 10);
> >> > zmq_recv (responder, buffer,10, 0);
> >> > printf ("%s\n", buffer);
> >> > sleep (1);          //  Do some 'work'
> >> > }
> >> > return 0;
> >> > }
> >> > when connecting ,the crash happened in the peer which installed
> >> > zeromq4.0.1..Just like the following.
> >> > Assertion failed: buffer_size == header_size (stream_engine.cpp:485)
> >> > Aborted
> >> > Thanks...
> >> >
> >> >
> >> > On Fri, Nov 22, 2013 at 8:12 PM, Pieter Hintjens <ph at imatix.com>
> wrote:
> >> >>
> >> >> OK, can you show us some very simple code that causes the problem for
> >> >> you? Then I'll test this on various versions of ZMQ.
> >> >>
> >> >> On Fri, Nov 22, 2013 at 3:55 AM, 舒友村 <shuyoucun at bwstor.com.cn>
> wrote:
> >> >> > Hi, Sorry, I donot understand "test off libzmq master" clearly. I
> >> >> > have
> >> >> > do
> >> >> > the test: used zeromq3.2.4 as the ROUTER peer, it doest crash when
> >> >> > DEALER
> >> >> > peer connect to ROUTER peer, but the ROUTER socket receive nothing
> >> >> > from
> >> >> > DEALER peer when use zmq_send() to send messages. Does not the
> >> >> > zeromq3.2.4
> >> >> > support to communicate wtih zeromq2.2? Thanks..
> >> >> >
> >> >> >
> >> >> > On Thu, Nov 21, 2013 at 11:36 PM, Pieter Hintjens <ph at imatix.com>
> >> >> > wrote:
> >> >> >>
> >> >> >> There was a bug in ZeroMQ 4.0.1 which might be causing this. Could
> >> >> >> you
> >> >> >> test off libzmq master and tell us if it still crashes?
> >> >> >>
> >> >> >> On Thu, Nov 21, 2013 at 4:31 PM, 舒友村 <shuyoucun at bwstor.com.cn>
> >> >> >> wrote:
> >> >> >> > HI, I used the DEALER and ROUTER sockets. when the DEALER socket
> >> >> >> > (zeromq2.2
> >> >> >> > )connect to ROUTER(zeromq4.0.1), the abort happened in handshake
> >> >> >> > when
> >> >> >> > connecting.I donot know whether it is not support this
> >> >> >> > usage.Thanks..
> >> >> >> >
> >> >> >> >
> >> >> >> > On Thu, Nov 21, 2013 at 6:48 PM, Pieter Hintjens <ph at imatix.com
> >
> >> >> >> > wrote:
> >> >> >> >>
> >> >> >> >> Hi, what socket types are you using on each side?
> >> >> >> >>
> >> >> >> >> -Pieter
> >> >> >> >> _______________________________________________
> >> >> >> >> zeromq-dev mailing list
> >> >> >> >> zeromq-dev at lists.zeromq.org
> >> >> >> >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > --
> >> >> >> >
> >> >> >> > best!
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > 舒友村
> >> >> >> >
> >> >> >> > _______________________________________________
> >> >> >> > 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
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > --
> >> >> >
> >> >> > best!
> >> >> >
> >> >> >
> >> >> >
> >> >> > 舒友村
> >> >> >
> >> >> > _______________________________________________
> >> >> > 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
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> >
> >> > best!
> >> >
> >> >
> >> >
> >> > 舒友村
> >> >
> >> > _______________________________________________
> >> > 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
> >
> >
> >
> >
> > --
> >
> > best!
> >
> >
> >
> > 舒友村
> >
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



-- 

best!


舒友村
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131127/05390704/attachment.html>


More information about the zeromq-dev mailing list