[zeromq-dev] Double connect problem in XREP to XREP

Antonio Delgado Peris antonio.delgado.peris at cern.ch
Wed Mar 9 17:23:03 CET 2011


Dear all,

I've recently started to play with zeromq. Sorry if this question has 
been answered before, I've been searching for it and was unable to find it.

I'm trying to connect a number of peers. I've thought of using XREP 
sockets for all of them (with different identities for each one), so 
they bind at a port and they can dynamically connect to each other when 
they discover about the others (each one keeps a list of the peers to 
which it is connected).

The problem comes when a peer tries to connect to one that has already 
connected to it: first A connects to B, then B connects to A, then at 
the next send (on either peer) I get:

     Assertion failed: ok (xrep.cpp:61)

So I guess zmq there're two identities for the same socket at the peer's 
XREP where it's just a double connect.

So, first, is this expected? If so, how could I avoid it? E.g., is there 
a way to list the identities already known by the XREP socket, so that a 
peer does not try to connect to one that is already there? Although for 
me, the most reasonable behaviour in this case would be that the second 
connect was translated to a no-op, given that there is already a 
connection to that identity (with same address).

Otherwise, I guess a solution for me would be to have two different 
XREPs, one for outgoing connections and one for incoming connections but 
that would mean that in some cases I would have repeated sockets A->B, 
B->A. Maybe that's not a problem, but I would rather give a try to 
understanding if the double connect problem is solvable before 
circumventing it.

In case it matters, I'm using:
     Linux (scientific linux 2.5, kernel 2.6.18-128)
     zeromq version 2.1.1
     python bindings version 2.0.10.1
     TCP addresses for these sockets

Thanks a lot for any reply.

Cheers,
    Antonio



More information about the zeromq-dev mailing list