---
title: "Across machines"
description: "Send a stream's tracks to a MoQ relay you run, Cloudflare's or moq.pro's, read them on any machine, and control another machine's runtime over ssh."
type: "docs-page"
url: "https://tatolab.com/docs/share/across-machines"
site: "Tatolab"
section: "Share"
---

# Across machines

> Send a stream's tracks to a MoQ relay you run, Cloudflare's or moq.pro's, read them on any machine, and control another machine's runtime over ssh.

Sharing beyond one machine works the same way as sharing between streams on it: a stream's `MoqGateway` publishes a broadcast at a [MoQ](https://datatracker.ietf.org/group/moq/about/) relay, and anything that can reach the relay reads its tracks. Only the gateway's settings say where the relay is. The rest of the stream is the same either way.

![A stream's gateway publishes one broadcast, <code>door-camera.hang</code>, at a relay, and a browser, a laptop and another stream all read it there.](https://tatolab.com/media/docs/relay-light.jpg)

## Pick a relay

`MoqGateway`'s `kind` says which relay it dials, and each kind takes its own settings:

| `kind` | The relay | Settings |
|---|---|---|
| `moq-relay` | The open-source [`moq-relay`](https://github.com/moq-dev/moq), run by you | `relay_url`; `token`, when the relay checks tokens; `certificate_fingerprint`, to pin a self-signed certificate |
| `cloudflare` | A relay Cloudflare provisioned for you | `relay_url`, which carries its token as the last path segment |
| `moqpro` | A [moq.pro](https://moq.pro) project | `project_id` and `signing_key`, the JWK moq.pro gave. The gateway renews its credential before it expires. |

Every kind takes `broadcast`, the name the relay serves the gateway's tracks under, as `<broadcast>.hang`. A gateway that loses its relay dials again.

- **A relay you run** is the private choice: your traffic passes through no one else's machine. Run it on a machine your others can reach, over your LAN, a VPN or a [Tailscale](https://tailscale.com) tailnet, and bind it to that address instead of loopback. [Share between streams](https://tatolab.com/docs/share/between-streams#run-a-relay) has a starting configuration.
- **A hosted relay** reaches anyone on the internet its tokens let in. Whoever operates it can see the media that passes through it.

### A self-signed certificate

A `moq-relay` with `[listen.tls] generate = [...]` makes its own certificate, which no client trusts by default. It serves the certificate's fingerprint over HTTP, on the same port:

```sh
curl http://relay.lan:4443/certificate.sha256
```

An `http://` relay URL, as in the examples here, has the gateway fetch that fingerprint from the relay as it dials, which suits a network you trust. To pin a certificate you've checked instead, give its fingerprint as `certificate_fingerprint` and use an `https://` URL.

## Send from one machine, read on another

On `door-box`, a stream encodes its camera and sends it through a gateway set to the shared relay:

```json title="door-box: the gateway"
{
  "name": "gateway",
  "type": "tatolab.moq:MoqGateway",
  "input_values": {
    "kind": "moq-relay",
    "relay_url": "http://relay.lan:4443",
    "broadcast": "door-camera"
  }
}
```

with a `MoqTrack` named `video` and a `MoqTrackSend` fed by the encoder, as in [Share between streams](https://tatolab.com/docs/share/between-streams#send-a-track). On your laptop, a stream with a gateway of its own, set to the same relay, reads it with a `MoqTrackReceive` (`broadcast` `door-camera.hang`, `track` `video`, `family` `packets`, `codec` `h264`) and decodes it.

- **Pull, never push.** A relay sends a track only to the readers that subscribe to it.
- **Send pictures encoded.** A picture's message names GPU memory on the machine that made it, which means nothing anywhere else. Encode it, and decode it where it's read.
- **Times line up.** Each object carries its message's timestamp, and the reader writes it at that time on its own clock, so Records and frames from the same moment stay paired.
- **Late groups are given up.** `max_age` on the receive says how far newer content may run past a missing group before it's skipped. Raise it on a lossy network.

Any MoQ client that reads hang broadcasts reads the same tracks, a browser player among them. The gateway publishes the broadcast's catalog, so a client knows each track's codec and size before the first frame.

## Keep tokens out of the graph

A relay's token or signing key is a secret, and the graph document is in the project's history. Hand it to the gateway on its `settings` input instead: a Records message there replaces the gateway's config values, and `null` unsets one. A small node of your own can read the runtime's environment, or your secret store, and write `{"token": ...}` to it once at start.

## Control another machine

Every `tatolab` command works on another machine's runtime when you run it there over `ssh`:

```sh
ssh door-box .local/bin/tatolab streams
ssh door-box .local/bin/tatolab logs --dir door-camera -f
```

`.local/bin/tatolab` is where the Linux installer puts it, relative to your home folder on that machine; a command run over `ssh` doesn't get `~/.local/bin` on its `PATH` on Debian and Ubuntu. An agent works the same way:

```sh
claude mcp add door-box -- ssh door-box .local/bin/tatolab mcp
```

The runtime's control is reachable only on its own machine, so `ssh`'s keys and permissions decide who controls it. `tatolab graph` names the machine it ran on under `machine`. Each project's [JSON Lines log](https://tatolab.com/docs/run/logs) is a file you can copy off, or ship to your own tools.
