Rubylight Download 7.0.3
On this page
  1. Invite someone
  2. What must be reachable
  3. The certificate warning
  4. Threat model
  5. For developers

Guests in the browser #

Rubylight docs › Play together · WebRTC server · Configuration

While you stream a game in the console's Stream page, up to four friends can watch it in their own browsers, and play along with a controller or a keyboard and mouse if you let them. They get a link, open it, type a name and see and hear your stream. They need no app, no account and no pairing. There are no relay servers in between: every guest connects straight to your PC.

To have a paired Nightjar or Moonlight device join the game another device plays, see Guests from other devices.

Invite someone #

  1. Turn on the WebRTC server and stream from the console's Stream page (Stream in the console).
  2. Under Guests, click Invite. Pick what guests can do and how long the link works, then Create link:
    • View only: picture and sound. Whatever their browser sends is dropped on the PC.
    • Controller (the default): their gamepads, each on a virtual pad of its own.
    • Controller, keyboard and mouse: also their keys and mouse, which control this PC as yours do. Keep these for people on your own network or VPN (The certificate warning).
    • The link expires after 1 hour, 24 hours (the default) or a time you set, from 5 minutes to 7 days.
    • Guests are says where your friends are:
      • This network or a VPN (the default): the link carries the address you opened the console at (your PC's LAN address when you opened it on the PC itself), on the guest port, TCP 47991.
      • On the internet: Rubylight asks your router to forward the guest ports at once (What must be reachable) and shows what the router did with each port, your public address, and whether guests on the internet can reach the PC. The link then carries the router's own internet address when it is public, or this PC's IPv6 address when only that is open. If nothing on the internet can reach the PC, the dialog says why (such as carrier-grade NAT) and what works instead: Tailscale or another VPN, IPv6, or forwarding the ports by hand.
    • Address is the address in the link. Type over it to use another one, such as a DNS name for your router; without a port the link uses 47991. The console remembers an address you type, one for each choice of Guests are, until you clear it.
  3. Copy the link and send it.

A guest types the name you will see and clicks Join. While they watch, a bar at the top of the picture shows that name, what the link lets them do, and Full screen, Mute and Leave; it hides after four seconds and comes back when they move the pointer or tap (with keyboard and mouse permission, where the pointer plays the game: when the pointer reaches the top edge, or with Ctrl+Alt+Shift+Z, which also releases the mouse and wheel until the guest clicks the picture again).

A guest who opens the link while you are not streaming sees "Waiting for the host" and joins when your stream starts. When your stream ends, every guest's ends with it; their pages wait for your next stream and join it while the link works.

Guests lists who is watching and every link that still works. Kick disconnects a guest; the link still works, so they can come back. Revoke withdraws a link: it opens nothing from then on, and whoever joined with it is disconnected. An expired link lets nobody new in; guests already watching stay until you kick them, revoke the link or stop streaming, and the link stays listed as Expired until they have gone, so you can still revoke it. Rubylight keeps links in memory only, so restarting it (or the PC) revokes them all. It keeps at most 16 links at once.

The guest port answers only while a link works or a guest is watching. Before your first link, and once every link has expired or been revoked and the last guest has left, it answers every request with "not found".

Guests see your stream exactly as you do: the same codec, resolution and frame rate, picked on your Picture panel. A guest's browser has to receive that codec over WebRTC: in the project's tests Chromium and Firefox receive AV1 and H.264, and HEVC only where the browser has an H.265 receiver (Browser support for video). A guest whose browser can't play it gets a message saying so.

What must be reachable #

On the local network, Tailscale or a VPN, nothing needs setting up: guests open the link at your PC's address.

From the internet, these must reach the PC. A link made for guests On the internet has the PC forward them itself through UPnP, PCP or NAT-PMP, also while automatic port forwarding (upnp) is off, and opens them in the IPv6 firewall on a PC that listens on IPv6 (address_family = both). The forwards last while such a link works or a guest who joined with it watches, and go within a minute after the last link expired or was revoked and its last guest left (at once when you revoke a link nobody watches with). Choosing On the internet forwards them for two minutes before you create the link, so the dialog can show what the router did. With upnp on, the PC forwards them while any link works or a guest watches. A router without UPnP, PCP and NAT-PMP needs them forwarded by hand:

What Port Notes
The guest page and its socket TCP 47991 The guest port (base port + 2). It serves /guest/ while a link works, and /play, the TV browser play page and its pairing socket, to the local network and Tailscale only.
Each guest's picture, sound and input UDP 8002-8005 webrtc_media_port + 1 to + 4: one port per guest.

Rubylight forwards nothing else for a guest link: never TCP 47990, the console's port, nor UDP 8000 or 8001 (the TV protocol and your own stream). Don't forward those by hand either. The console tells your local network from the internet only by the address a connection comes from, and a router that rewrites source addresses, a tunnel (Cloudflare Tunnel, ngrok), a reverse proxy or netsh portproxy makes internet connections look local. The guest port has no console behind it, but it has the play page, which tells the local network from the internet the same way. Rubylight catches two of these setups: a router that rewrites forwarded connections to its own address (the PC's default gateway) is refused, and a 100.64.0.0/10 address counts as Tailscale only on the PC's Tailscale address, not when a neighbour behind your ISP's carrier-grade NAT reaches the forwarded port. A tunnel or reverse proxy on the PC (Cloudflare Tunnel, ngrok), netsh portproxy, or a router that rewrites to another address still makes an internet browser look local to the play page. It can then ask to pair, but nothing pairs until you type the PIN it shows in the console, which shows the address each request came from (Play in a TV browser). Type a PIN only for a device you are holding, from the address you expect.

When a guest joins, the PC looks up the link's address (only the one you typed, never one a guest sends) and offers it to the guest's browser beside its own, so a forwarded UDP port is found.

Rubylight uses no STUN or TURN server and no relay for guests. The address in a link for the internet is the one the router that forwarded the ports reports, and only when it is public. With Play over the internet on, the host also asks public STUN servers (Play over the internet); when they see the PC at another address, a second NAT stands in front of the router and the dialog says the PC is out of reach. Each guest's browser connects to the PC's UDP port; the PC learns the guest's address from that connection. A guest behind its own router needs no setup. A PC that can't take incoming connections (behind carrier-grade NAT, or a router you can't configure) can't have guests from the internet; the invite dialog says so, and Tailscale or IPv6 gets around it. A friend whose Nightjar is paired with this PC can instead join your game as a guest from another device: with Play over the internet on and When another device joins the running game set to Ask the player or Let in without asking, it reaches the PC without forwarded ports, also behind carrier-grade NAT, after it was on the PC's network once. A guest whose browser gets no answer on the UDP port sees that within 8 seconds, with the port and what to ask you for (what each message means).

The certificate warning #

The guest port uses the console's own certificate, which browsers on the PC trust and other devices don't (Getting started). A guest therefore sees a certificate warning when they open the link, and that warning means their browser cannot tell your PC from a machine in between. Whoever sits between you and the guest (on public Wi-Fi, a network you don't run, or the internet) can show the same warning with a certificate of their own, read the token as the page sends it and use the link as your guest: watch, play, and with keyboard and mouse control your PC. The stream's own encryption (DTLS-SRTP) does not help, because its keys travel over that same connection.

Threat model #

What a link gives: the guest page and its socket, and through them one seat in your running stream with the link's permission. Nothing else.

Text and voice chat are not part of this; use a voice app beside it.

For developers #

The owner's API, behind the console sign-in (rust/host/src/web/guests.rs):

Request Body Answer
GET /api/guests {"streaming", "max_guests", "port", "media_ports", "invites": [{"id", "permission", "created", "expires", "internet"}], "guests": [{"id", "name", "permission", "invite", "since"}]}; invites includes expired links a guest still watches with
GET /api/guests/addresses {"addresses": [...]}: this PC's LAN addresses
GET /api/guests/internet What a link for the internet can use: {"checking", "runs", "method", "error", "ports": [{"protocol", "port", "external", "reason"}], "publicIpv4", "routerIpv4", "ipv6", "address", "notes", "internetPlay", "ipv6Listening", "guestJoin"}. address is the public address (or [IPv6]) with the guest port, null when nothing on the internet reaches the guest ports; checking is true until the router was asked after the last request; ipv6Listening says the host listens on IPv6, so the router can open the guest ports to it; guestJoin is the When another device joins the running game setting, whose values other than off let a paired friend join as a guest
POST /api/guests/internet {} Forwards the guest ports for two minutes, before a link holds them, and answers like GET
POST /api/guests/invite {"permission": "view" | "controller" | "controller-keyboard-mouse", "seconds": 300..604800, "address": "<host>[:port]", "internet": true | false} (address and internet optional) {"invite": {...}, "token"}; 409 with 16 links open. internet keeps the guest ports forwarded while the link works or a guest watches with it
POST /api/guests/revoke {"id": "<invite id>"} {}, also for an expired link someone still watches with; 404 otherwise
POST /api/guests/kick {"id": <guest id>} {}; 404 when that guest is not watching

The guest socket, wss://<host>:47991/guest/signal with subprotocol rubylight.guest.v1 and the page's own origin (rust/host/src/webrtc/guests.rs), takes JSON text messages:

The offer is the owner's stream's: the same codec and Opus layout, with the control and gamepad DataChannels of The host's offer. A guest with keyboard and mouse opens the input channel (The input channel); the host accepts it only for that permission. The guest page is built by rust/web/vite.guest.config.ts into dist/guest.

View this page on GitHub