Relay¶
What it runs¶
The relay is the optional hosted or self-hosted bridge for remote dashboard and remote MCP access to a local daemon. Local daemons connect outbound over WSS; the relay tunnels dashboard HTTP/SSE calls and relay MCP requests to the daemon. Between an owner's daemons it carries one thing: cross-machine requests (machine_request frames), which it re-issues to the target under its own request id, naming the sending machine. See circles across machines and multiple machines.
Long responses through the hosted relay¶
The hosted relay sits behind a Google load balancer, which ends any response
still open after its backend timeout. The chart sets that to an hour
(relay.backendTimeoutSec, through a GCPBackendPolicy); the default would be
30 seconds, which cut every event stream. A client reopens a closed stream with
?since=<last event id> and receives only what it missed. The daemon tunnel is
a WebSocket, where the timeout is an idle limit that its pings keep from firing.
Deploying the hosted relay¶
A relay deploy restarts the relay, which briefly cuts every daemon's tunnel and
every phone or dashboard session. The hosted relay (.github/workflows/relay.yml)
therefore deploys on purpose:
- A push to
maindeploys at once when it changes the relay server (daemon-go/relayserver/**), the entry file and Go dependencies (daemon-go/main.go,go.mod,go.sum), the hosted dashboard (web/**), theDockerfileand.dockerignore, the chart, or the workflow. - The hosted dashboard is the relay's.
repowire.io/dashboardhands off to the relay, which serves the dashboard built into its image.web.ymldeploys the landing site (repowire-web), not the dashboard you sign in to. A merge that touchesweb/therefore deploys the relay. - Everything else in the image (the CLI, config and daemon packages) waits for the next deploy, which is one of:
- a release tag (
v*); - a manual run (
gh workflow run relay.yml); - the daily run, scheduled for 04:00 UTC, which deploys only if the image's inputs changed since the commit that is live. GitHub may run a schedule hours late or skip it under load (on 2026-12-01 it ran at 22:11 UTC; on 2026-12-02 it did not run), so treat it as a backstop, not a deadline.
- Check what is served, not the run. After a deploy, open the hosted dashboard and look for something only the new build has; a green run or a 200 does not show which build is serving.
- Every deploy:
- builds and deploys one commit;
- runs one at a time;
- refuses a commit older than the live one;
- does nothing for the live commit, unless forced (
forceon a manual run).
Pull requests build the image in CI without deploying.
A restart is short. On shutdown the relay stops taking daemons (/health
answers 503), fails the requests waiting on them, and closes each daemon's
tunnel with status 1012 (service restart). It then exits within about 8
seconds. A daemon that sees 1012 redials at once, then every second for 60
seconds, instead of backing off. The new relay is marked ready within seconds
of starting. The daemon log shows relay: relay restarting, reconnecting in ….
Share links survive a restart. They are stored in a relay_shares table, in
the file named by REPOWIRE_RELAY_STATE_DB, or else in the OAuth database
(REPOWIRE_RELAY_OAUTH_DB). With neither set, they are kept in memory and end
with the process, and the relay logs that when it starts. Each owner's
home machine is kept in the same place, in
a relay_homes table.
Tunneled frame size¶
The relay and the daemon each read frames of at most 16 MiB. A frame carries its body base64-encoded, so about 12 MiB of request or response body fits. - A tunneled request larger than that gets 413 from the relay. - A cross-machine request that large gets 413 on the sending daemon. - A response too large becomes 502 for that request alone.
None of these reach the socket, so the tunnel stays up for every other request. A caller that goes away (a closed app request or stream) never closes the shared link either. Its frames are dropped, and a frame already on the wire is finished.
Tunneled request deadlines¶
A tunneled request waits 30 seconds for the daemon by default, then gets 504. A caller that long-polls through the relay (POST /asks/{cid}/wait, POST /questions/ask-blocking, which wait up to 50 and 55 seconds) states its own deadline in seconds with the X-Repowire-Timeout header. The relay caps it at 90 seconds and sends it to the daemon as timeout_ms in the http_request frame, and the daemon's relay client bounds the local request by the same value (also capped at 90), counted from when the frame arrives and ending a little before the relay's (1 second, or a tenth of a short deadline), so the daemon gives up first and nothing runs after the relay has answered 504. A request still queued for a free worker when its deadline passes is dropped unrun. At most half of the daemon's 16 tunnel workers may hold a deadline longer than the default at once; one more long-poll is refused at once with 429, so long-polls cannot starve ordinary requests. The route's own cap still applies. The relay's MCP get_reply sends its wait plus 10 seconds. A relay or daemon from before this change keeps 30 seconds on its side, so both must be updated for longer polls to pass.
Hosted relay¶
Enable the hosted relay with:
Then use https://repowire.io/dashboard for remote dashboard access.
The relay landing page accepts the relay key from setup and redirects to the dashboard when the matching daemon is connected. Missing, invalid, or disconnected keys return to the landing page with an inline error.
The logged-out landing page plays a decorative dotted orb → Repowire R reveal once on arrival, then holds the mark. It does not reflect peer or connection status. Reduced-motion preferences show the static R, which also remains visible without JavaScript. The relay-key form is available throughout.
Self-hosted relay¶
Self-hosting runs the same relay server under your own deployment and points the daemon at your relay URL.
Diagnosing a disconnected relay¶
If the dashboard login bounces back to the landing page with no_daemon, or peers do not appear in the remote dashboard, the daemon's relay client is not connected — the relay has no daemon to bind the session to. Check live relay state on the local daemon:
The relay block reports the real connection, not just the config flag:
status: connected— the relay client holds a live WebSocket.status: connecting— the reconnect loop is running but not yet connected.status: down— relay is enabled but not connected;last_error/last_error_atcarry the cause. Hitting/healthalso lazily relaunches the loop if it had stopped.status: disabled— relay is not enabled in config.
relay_mode remains the config intent (relay.enabled); relay.status is the truth. The relay client pings the relay every 20 seconds and reconnects when a ping goes unanswered, so a half-open connection is detected rather than silently wedging. A frame being written counts as progress. A large tunneled response on a slow uplink can take longer than one ping, and the ping waits behind it. So the client sends no ping while a frame is being written, or while the bytes written so far could still be leaving the socket buffer at 64 KiB/s. At most 8 MiB is counted as still waiting after a write returns, so this lasts about 2 minutes at most. A ping holds the writer, so no frame can get in front of it. A frame still being written after 30 seconds plus its size at 64 KiB/s closes the link, as does an unanswered ping once nothing is draining. A request or stream that ends, such as the app closing a live view, never closes the shared link. Its remaining frames are dropped, and a frame already on the wire is finished. The daemon log records each reconnect's cause (relay: ping timeout or relay: a N-byte frame has been writing for …), and any frame write that took 5 seconds or more.
Push notifications¶
The relay sends APNs pushes for the iOS app, which is the ios surface of the human inbox. The daemon decides what reaches the human and owns the device tokens (/push/devices, stored in its SQLite state); each push frame it sends over the relay WebSocket names its target tokens. The relay only holds the APNs key, and answers each frame with APNs' outcome, which the inbox records as the push's receipt.
Configure the relay with all four variables, or none to leave push off:
| Variable | Value |
|---|---|
REPOWIRE_RELAY_APNS_TEAM_ID |
Apple developer team id |
REPOWIRE_RELAY_APNS_KEY_ID |
Key id of the .p8 APNs auth key |
REPOWIRE_RELAY_APNS_KEY_PATH |
Path to the .p8 file |
REPOWIRE_RELAY_APNS_TOPIC |
The app's bundle id (io.repowire.app) |
REPOWIRE_RELAY_APNS_BINDINGS_DB |
Optional. SQLite path for device-token bindings, so they survive a relay restart. Without it they are kept in memory. |
The relay sends a push only to device tokens bound to the pushing daemon's relay key. A token binds once the device proves it holds the token; knowing a token is not enough, because Apple treats tokens as identifiers, not secrets. The binding works like this:
- The app registers its token with
POST /push/devicesthrough the tunnel. - Once the daemon accepts the registration, the relay sends that token a background push (no alert or sound) carrying a random nonce. Only the device that holds the token receives it.
- The app echoes the nonce to
POST /push/devices/verify {token, nonce}. The relay answers this route itself; it is not tunneled. - The token binds to the registering user only if the nonce matches within 10 minutes and the echo arrives under the same relay key. Each nonce works once.
Another tenant who registers your token triggers a challenge on your phone that they cannot read, so they cannot take the binding. Each key has its own challenge per token, so their registrations cannot replace yours and block your phone from verifying. One key may have at most 20 open challenges. A verified registration under a different key does move the token, since only the phone's holder can complete one. A tunneled DELETE /push/devices/{token} unbinds the token for its owner. Challenges count toward the push rate limit.
A token not bound to the pushing daemon's key is skipped and reported back as unbound. The daemon keeps it, and the app re-registers and re-verifies on its next launch. One key holds at most 20 bindings, and the oldest is dropped first.
Each push names an environment per device (sandbox for development builds, production otherwise). The relay checks a rate limit of 30 pushes per minute per relay key as each frame arrives, and sends from a bounded queue (4 workers, 16 queued per daemon connection). It refuses at once anything over either limit, and sends to at most 10 devices per push. Tokens APNs rejects as unregistered or invalid are reported back to the daemon, which deletes them. Failures are recorded on the message's trace as surface_failed with surface: ios.
Related¶
Remote MCP and OAuth¶
See Relay MCP for the OAuth connection flow, remote tools, token refresh and revocation, and portable/Claude plugin installation. The remote surface is a scoped companion to the local daemon MCP tools.
OAuth-enabled relay deployments use one replica and a retained RWO volume. The Recreate rollout briefly disconnects clients while the relay pod restarts; durable grants survive, and daemons reconnect through their existing relay transport.
The hosted deploy workflow selects oauth.proxyMode=gclb and reads the gateway's
forwarding IP into oauth.gclbForwardingIP. Registration limits verify the GFE
socket source and Google's appended X-Forwarded-For suffix. Cloudflare's visitor
header is trusted only when the load balancer's recorded source is Cloudflare;
direct-origin requests are limited by the IP Google recorded instead. No
Cloudflare-only firewall or Cloud Armor policy is required for this selection.
The chart defaults to direct for self-hosters. Startup logs state the configured
mode. After rollout, verify registration budgets through Cloudflare and directly
through the gateway; the pod-level header path has not been measured on the live
service yet. Adding a sidecar or changing the gateway type requires revisiting
this trust chain. Health checks, local daemon endpoints, and established MCP
connections do not pass through the registration limiter. See the
relay MCP reference for header fallbacks and CIDR
maintenance.