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

Pieter Hintjens ph at imatix.com
Tue Mar 26 19:07:03 CET 2013

On Tue, Mar 26, 2013 at 5:29 PM, Anoop Karollil
<anoop.karollil at gmail.com> wrote:

> If that is the case, there is no getting around having to resend the
> first message that you send to a bound socket because it will always be
> in a mute state initially?

The man page is a bit dry. What is really going on is this:

* 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).

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 tend to stay away from ROUTER-ROUTER for this reason. It's neater
IMO to use a DEALER to ROUTER model as we do in Zyre.


More information about the zeromq-dev mailing list