You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 34ced44
Browse filesBrowse the repository at this point in the historyBrowse files
Reach a paired computer through the relay sync uses (#2073)
* fix: reach a paired computer through the relay sync uses
codeaf serve and chat --at fall back to the relay sync resolves, the relay
client keeps the relay address's path, the carrier rides a WebSocket (with a
fallback to the raw upgrade for older relays), the hosted relay gains the
machine doors, and upstream failures become plain sentences.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: address review of the machine doors
A full machine answers 429 on both relays, a registration being decided is
not taken over, a closed stream is not closed twice, a running serve waits
out a redeploying relay, frames reuse one buffer, the door paths are one
constant, per-address limits match codeaf relay, and the hosted README
lists the binding, the migration and the doors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* style: gofmt relay server
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
workspace:=flags.String("workspace", "", "directory a connection works in when it does not name one; empty is the directory this command was run in")
264
-
relayAddress:=flags.String("via", "", "the sync address to be reachable through; empty reads "+pair.RelayEnv)
265
+
relayAddress:=flags.String("via", "", "the sync address to be reachable through; empty reads "+pair.RelayEnv+", then the address this machine syncs through")
// THE HONEST STATE, AND THE ONE MOST PEOPLE WILL MEET. The relay is a
279
-
// service and this build does not assume one exists.
279
+
// Only a machine whose person turned sync off and named no relay
280
+
// gets here; every other machine has sync's address.
280
281
returnerrors.New("no sync address is set up on this machine, so there is nowhere to be reachable from — set "+pair.RelayEnv+" to your sync address, or let people in over ssh with `codeaf chat --host` from their side")
title: codeaf serve and chat --at work through the relay your chats already sync through
4
+
pr: 2073
5
+
surface: [remote, docs]
6
+
invalidates:
7
+
- "codeaf serve and chat --at needed CODEAF_RELAY or a saved relay file; with neither they said no sync address was set up. They now fall back to the relay sync resolves (CODEAF_SYNC_URL, the relay a pairing saved, then the hosted relay)."
8
+
- "The relay client dropped the path of a relay address, so https://host/fabric was called at https://host/v1/engine. It now calls https://host/fabric/v1/engine and /fabric/v1/dial/<name>, as every other client does."
9
+
- "The machine carrier was only the raw aforge-relay/1 HTTP upgrade. It now rides a WebSocket offering that protocol and falls back to the raw upgrade when a relay answers 426; codeaf relay accepts both."
10
+
- "The hosted relay had no machine doors and answered /v1/engine with 404. It now serves /v1/engine and /v1/dial/<name> through one Durable Object per machine name, which needs the v4-machines migration and the MACHINE binding in a deployment's config."
11
+
- "codeaf serve said lost sync on every retry and quit when the relay still held its own name from a dropped connection. It now says it once per outage and waits the stale name out."
12
+
---
13
+
14
+
A relay that is down, or one that cannot connect machines, is now one sentence naming the relay and what
15
+
to try, never an upstream body such as `error code: 522`.
router setting. That machine dials *out* to a relay and stays connected, which is why
35
35
firewalls and NAT stop mattering.
36
36
37
-
**This needs a relay service, and there is not one running yet.** Until one is switched
38
-
on, `--at` prints:
39
-
40
-
```
41
-
no service address is set up on this machine, so --at has nowhere to look for otter-lamp-42 — set CODEAF_RELAY to a service address, or reach that machine with --host over ssh
42
-
```
37
+
**There is nothing to set up.** Both machines go through the relay their chats already
38
+
sync through: the hosted relay, unless sync was pointed somewhere else with
39
+
`CODEAF_SYNC_URL` or by pairing. `CODEAF_RELAY`, or `--via` on `codeaf serve`, picks a
40
+
different relay for this door alone, such as one you run yourself.
43
41
44
42
`--host` works today and is not going anywhere. If you can already reach the machine that
45
43
way, use that; the two doors are compared at the bottom of this page.
@@ -65,19 +63,39 @@ digits, the same every time, on any relay. You cannot pick a nicer one, and nobo
65
63
can register under yours while your machine is connected.
66
64
67
65
`--workspace` is the directory a connection works in when it does not name one; empty
68
-
means the directory you ran the command in. `--via` beats the`CODEAF_RELAY`
69
-
environment variable.
66
+
means the directory you ran the command in. The relay is, in order: `--via`, the
67
+
`CODEAF_RELAY`environment variable, then the relay this machine syncs through.
70
68
71
69
Running it twice on one machine is refused, because there is only one of it:
72
70
73
71
```
74
-
this machine is already connected to the service as otter-lamp-42 — there is only one of it, so close the other `codeaf serve`
72
+
this machine is already connected to sync as otter-lamp-42 — there is only one of it, so close the other `codeaf serve`
73
+
```
74
+
75
+
## codeaf serve when the network drops or the relay says no
76
+
77
+
If the network drops while it runs, it says once:
78
+
79
+
```
80
+
lost sync — trying again
75
81
```
76
82
77
-
With no relay set up at all it says:
83
+
and keeps trying, waiting a little longer each time up to a minute, until it prints its
84
+
name and code again. It does not need restarting, and devices reach it as soon as it has.
85
+
86
+
A relay that answers but cannot connect machines, such as an older sync service, stops
87
+
it with:
78
88
79
89
```
80
-
no service address is set up on this machine, so there is nowhere to be reachable from — set CODEAF_RELAY to your service address, or let people in over ssh with `codeaf chat --host` from their side
90
+
the service at https://service.example.com syncs chats but does not connect machines — run your own with `codeaf relay` and set CODEAF_RELAY to it, or reach that machine with --host over ssh
91
+
```
92
+
93
+
A relay that cannot be reached when it starts stops it with the sentence in *When --at
94
+
will not open*. With sync turned off (`CODEAF_SYNC_URL=off`) and no `CODEAF_RELAY`, there
95
+
is no relay at all:
96
+
97
+
```
98
+
no sync address is set up on this machine, so there is nowhere to be reachable from — set CODEAF_RELAY to your sync address, or let people in over ssh with `codeaf chat --host` from their side
81
99
```
82
100
83
101
Ctrl+c ends it, and the machine gives its name back on the way out:
@@ -351,9 +369,9 @@ that still has it in the list, which is what revoking removes.
351
369
352
370
## When --at will not open
353
371
354
-
There are four different reasons, and each says which one it is, in one sentence.
372
+
There are five different reasons, and each says which one it is, in one sentence.
355
373
356
-
**No relay is set up on this machine:**
374
+
**No relay is set up on this machine** (sync is off and `CODEAF_RELAY` is empty):
357
375
358
376
```
359
377
no service address is set up on this machine, so --at has nowhere to look for otter-lamp-42 — set CODEAF_RELAY to a service address, or reach that machine with --host over ssh
@@ -365,6 +383,12 @@ no service address is set up on this machine, so --at has nowhere to look for ot
365
383
the service at https://service.example.com cannot be reached from here — check this machine's network, or reach that machine with --host over ssh
366
384
```
367
385
386
+
**The relay answers but cannot connect machines:**
387
+
388
+
```
389
+
the service at https://service.example.com syncs chats but does not connect machines — run your own with `codeaf relay` and set CODEAF_RELAY to it, or reach that machine with --host over ssh
390
+
```
391
+
368
392
**The relay is fine and that machine is not connected to it:**
369
393
370
394
```
@@ -464,15 +488,18 @@ sitting at. They differ only in how the two halves reach each other.
464
488
465
489
||`--host`|`--at`|
466
490
| --- | --- | --- |
467
-
| Needs |`ssh <machine>` already works |a relay service, and one pairing|
491
+
| Needs |`ssh <machine>` already works |one pairing; the relay is the one sync uses|
468
492
| Set up on the far machine | nothing |`codeaf serve` running |
469
493
| Works through NAT and firewalls | only if ssh does | yes — that machine dials out |
470
494
| Anything in the middle | nothing of ours | a relay that cannot read the conversation |
471
-
| Available today | yes |not until a relay is running|
495
+
| Available today | yes |yes|
472
496
473
497
**Prefer `--host` when ssh works.** It has nothing between the two machines, nothing to
474
498
set up, and no service to depend on. `--at` is for the machine ssh cannot reach.
475
499
500
+
Both machines must use the same relay. If one syncs through a relay of your own and the
501
+
other through the hosted one, set `CODEAF_RELAY` to the same address on both.
502
+
476
503
Both open the same surface with the same limits — what does and does not work over a
477
504
connection is a property of the connection, not of which of these two doors opened it.
0 commit comments