BlueZero (BØ)
Middleware for distributed applications
Connecting remote nodes

When distributing nodes across multiple machines, you must make sure that:

Reaching the resolver node

Nodes by default will try to reach resolver at tcp://localhost:22000, which only works when testing all nodes on the same machine. When the resolver node is on another machine, (for example the machine hostname is resolver-node-host.local) the environment variable B0_RESOLVER must be set to the correct address, e.g.:

export B0_RESOLVER="tcp://resolver-node-host.local:22000"

prior to launching every node, or in .bashrc or similar.

When B0_RESOLVER is not specified it defaults to "tcp://localhost:22000".

Reaching every other node

Nodes also need to be able to reach each other node. When a node creates a directly addressed socket, such as b0::ServiceClient or b0::ServiceServer, it will advertise that socket name and address to resolver.

Since there is no reliable way of automatically determining the correct IP address of the node (as there may be more than one), by default the node will use its hostname when specifying the socket TCP address.

This requires that all machines are able to reach each other by their hostnames. This is the case when there is a name resolution service behind, such as a DNS, or Avahi/ZeroConf/Bonjour.

Suppose we have a network with two machines: A and B. Machine A hostname is alice.local, and machine B hostname is bob.local.

If from machine A we are able to reach (ping) machine B by using its hostname bob.local, and vice-versa, from machine B we are able to reach machine A by using its hostname alice.local, there is no additional configuration to set. Otherwise, we need to explicitly tell how a machine is reached from outside (i.e. what's the correct IP or hostname), by setting the B0_HOST_ID environment variable, e.g.:

export B0_HOST_ID="192.168.1.3"

When B0_HOST_ID is not specified it defaults to the machine hostname.

Example

Suppose we have a network with two machines: A and B.

By default, nodes will use their hostnames when announcing socket addresses. We override this behavior, by setting B0_HOST_ID to the machine IP address.

Machine A - starting resolver

On machine A we run

export B0_HOST_ID="192.168.1.5"
./resolver

to run the resolver node.

Machine A - starting subscriber

On machine A we run

export B0_HOST_ID="192.168.1.5"
./examples/publisher_subscriber/subscriber_node

to run the subscriber node.

Note that for this machine we don't need to specify B0_RESOLVER, because the default value (tcp://localhost:22000) is good to reach the resolver socket.

Machine B - starting publisher

On machine B we run

export B0_HOST_ID="192.168.1.6"
export B0_RESOLVER="tcp://192.168.1.5:22000"
./examples/publisher_subscriber/publisher_node

to run the publisher node.