[zeromq-dev] Sending via ROUTER socket to ROUTER socket fails initially with "No route to host"

Anoop Karollil anoop.karollil at gmail.com
Tue Mar 26 22:09:04 CET 2013

On 13-03-26 11:07 AM Pieter Hintjens <ph at imatix.com> wrote to ZeroMQ 
development list <zeromq-dev at lists.zeromq.org> :

> * 0MQ sockets manage a set of "pipes" to connected peers
> * A pipe is created either on a connect (at once) or when an incoming
> connection arrives
> * No pipe means messages can't be sent... (the mute state)
> So if you bind a socket and then connect to it, there will be an
> arbitrary period when you can't send. Using ZMQ_MANDATORY means you
> get an error (otherwise the message is simply dropped at once).

Thank you for clearing that up.

> Once the pipe is there, you can send messages. The standard pattern
> for a bound socket is to wait for an incoming message, which
> guarantees the pipe is there. But you can also use other strategies,
> like pausing and retrying.

I am actually following the standard pattern for a bound socket but not 
in the previous example code. Attached are the broker and client split 
up into two separate programs that can be run independently and lets the 
bound broker socket receive first and the connected client socket send 
after. And yes, like you said, the send after connect succeeds if there 
is a pause in between.

Would it be possible to make the connect call block till the pipe is set 
up? The failure would actually get handled by higher level reliability 
mechanisms, but I found the behaviour weird.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: broker.py
Type: text/x-python
Size: 265 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130326/68e36ff1/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: client.py
Type: text/x-python
Size: 387 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130326/68e36ff1/attachment-0001.py>

More information about the zeromq-dev mailing list