Running the collaboration relay locally¶
Audience: anyone who wants to host a session · ~6 min read · Prerequisites: Live collaboration
Live Model Session (Tools > Collaboration; see Live collaboration for how to use it) does not connect peers directly. Every peer connects to a
small relay server — open-collaboration-server
from the Open Collaboration Tools project — which creates rooms, hands out
room codes, and forwards the (end-to-end encrypted) Yjs updates between peers. The relay never runs
struktJS and never sees decrypted model content; it only routes messages.
struktJS's Live Model Session defaults to a local relay at http://localhost:8100/. It does not talk to
the public https://api.open-collab.tools/ unless you type that URL yourself. (Theia's separate, stock
Collaboration: Share Workspace… feature does default to the public relay, but it only syncs plain text and
is not used for .model.py/.model.js files, and the Relay server URL preference changes only the Live Model Session relay, not that stock feature's server.)
Start a relay¶
No install into the repo is needed — run it with npx:
OCT_ACTIVATE_SIMPLE_LOGIN=true npx open-collaboration-server
It prints Open Collaboration Server listening on localhost:8100. Quick check:
curl http://localhost:8100/api/meta
# {"owner":"Unknown","version":"0.3.1","transports":["socket.io"]}
OCT_ACTIVATE_SIMPLE_LOGIN=trueenables the built-in "just type a display name" login. Without it the server expects an OAuth provider (OCT_OAUTH_*variables), which you don't need for local use.- The binary is also named
oct-server. Stop it withCtrl+C. Leave it running in its own terminal while you use struktJS.
Options¶
| Flag / variable | Default | Meaning |
|---|---|---|
-p, --port <n> |
8100 |
Port to listen on |
-h, --hostname <host> |
localhost |
Interface to bind. Keep localhost unless you add TLS (see below) |
OCT_ACTIVATE_SIMPLE_LOGIN |
off | true = name-only login (local/dev use) |
OCT_BASE_URL |
derived | Public URL of the relay, used in links it generates |
OCT_CORS_ALLOWED_ORIGINS |
any | Restrict which web origins may call the relay |
OCT_SERVER_OWNER |
Unknown |
Name shown in /api/meta |
Example on another port: OCT_ACTIVATE_SIMPLE_LOGIN=true npx open-collaboration-server --port 9100.
Point struktJS at it¶
- Start the relay (above) and start struktJS (
npm startornpm run dev). - Run Share Model Session (Live)… — with the default relay (
http://localhost:8100/) nothing needs configuring. For a different port or host, set the Relay server URL setting (collabServerUrl; see Preferences) first, or just type the URL into the Collaboration server URL prompt. - Send the room code or join link to a collaborator, who runs Join Model Session (Live)…. The host gets an "Allow name to join?" prompt for every join request.
To try it yourself on one machine, open the IDE in two browser windows (use a private window for the second so it gets its own session) and share from one, join from the other.
Relay URL rules¶
struktJS only accepts https:// / wss:// relay URLs, except for loopback addresses
(localhost, 127.x.x.x, [::1]), which may use plain http:// / ws://. To use a relay on your own network
without TLS, turn on Allow plain-HTTP relay on a local network (collabAllowInsecureRelay); it permits
private-network addresses only (192.168.x.x, 10.x.x.x, 172.16-31.x.x, link-local, *.local), never public
hosts. URLs containing a username or password are rejected. A join link that points at a relay different from your configured one shows a
prominent warning before you accept it. See Security and privacy.
Live Model Session also encrypts content in the browser using window.crypto.subtle, which browsers only
provide in a secure context — HTTPS or http://localhost. Opening the IDE via a LAN IP over plain HTTP
makes that unavailable.
Collaborating across machines¶
The defaults are deliberately local-only: the relay binds localhost, and the IDE backend binds
127.0.0.1 (npm start passes --hostname 127.0.0.1). To collaborate with someone elsewhere:
- Run the relay on a host both of you can reach and put it behind TLS (a reverse proxy such as Caddy or
nginx giving it an
https://URL). SetOCT_BASE_URLto that URL and, ideally,OCT_CORS_ALLOWED_ORIGINSto the origins your IDEs are served from. - Each person then sets Relay server URL (
collabServerUrl) to thathttps://URL. - Do not solve this by binding the relay to
0.0.0.0over plain HTTP: struktJS rejects that URL for public hosts (and accepts it for a private-network address only if you opt in with the setting above), and simple login has no real authentication. - Do not expose the IDE's own backend (port 3000) for this. It runs a terminal and file access as your user and has no login; the relay is the only thing collaborators need to reach.
Troubleshooting¶
- "No open-collaboration-server reachable" / connection refused — the relay isn't running, or it's on a
different port than your Relay server URL setting. Check with
curl http://localhost:8100/api/metaandlsof -iTCP:8100 -sTCP:LISTEN -n -P. - Port already in use — another relay is already running (check the
lsofcommand above), or pick another port with--portand updatecollabServerUrl. - Session ends when the host reloads — the relay closes a room when its original creator disconnects for more than ~30 seconds. struktJS silently resumes a reload that completes within about 20 seconds; a longer outage ends the room.
- Integration tests — the Playwright collab suites (
tests/test-ui-collab.spec.js, the Theia collab specs) need a live relay athttp://localhost:8100(override withCOLLAB_TEST_SERVER_URL) and skip with a hint if none is reachable. Start it with the command above first.
See Collaboration internals for how the session, host-approval and resume logic work.