Multi-machine setups | Multi-machine setups

Multi-machine setups

When you configure a machine in Viam, you’re describing one computer running viam-server and the components attached to it. Three situations call for reaching outside one computer:

Under the hood, viam-server on one machine opens a gRPC connection to viam-server on another.
The remote server’s components and services join the local resource graph.
In your code they look like any other resource on the local machine: same API, same method calls, no separate client object.
Unless you configure a prefix, even the name stays the same.

Viam gives you two ways to create this connection: sub-parts and remote parts.

Pick a pattern

Sub-part Remote part
Who writes the config Viam cloud, through the app You, with address + API key
Who sees whose resources Main sees the sub; the sub cannot see the main Either direction, or both, by configuring each side
Shared by multiple machines No: each sub-part belongs to exactly one main Yes: any number of machines can connect in
Cross-organization No: must be in the same organization Yes

Three common scenarios:

Accessing remote resources in code

No special client, no new connection, no “remote” flag in your API calls.
Resources from a sub-part or remote part appear in the same resource list as your local components:

my_arm = Arm.from_robot(machine, "arm-1")          # local or remote, same call
my_camera = Camera.from_robot(machine, "wrist-camera")

If you configured a prefix on the remote, it is prepended to every remote resource name with no separator:

# Remote configured with prefix "end-effector"
gripper = Gripper.from_robot(machine, "end-effectorgripper")

When two connected parts export resources with the same name, a prefix disambiguates them.

What happens on disconnect

Two kinds of disconnect matter.

A remote part goes offline.
The connection is monitored in the background and reconnects automatically.
While the remote is down, its resources are marked unreachable and calls against them return an error.
Local resources on the main part keep running.

A controlling client disappears.
Every client connected to viam-server sends a periodic session heartbeat.
If the client goes silent (network loss, crashed process), viam-server automatically calls Stop() on the resource the client most recently commanded.
A rover will not keep driving, an arm will not keep moving, and a gripper will not keep closing when the commanding process vanishes.
This applies equally to local and remote resources.

For the lower-level details of how machines communicate, see Machine-to-machine communication.