Skip to content

swsrsSimple WebSocket Relay Service

Tunnel two peers behind NAT through a tiny self-hosted relay. One ~7 MB binary. OIDC-gated admin, opaque per-slot tokens on the wire. First-class Go and TypeScript SDKs so your app becomes the peer — no extra daemons to install.

What it's for

You have a service behind NAT — a diagnostic probe, a dev server, a customer's machine — and you need to reach it from somewhere else without poking holes in firewalls or running a VPN. swsrs is one rendezvous endpoint that both sides open an outbound WebSocket to. No port forwarding, no inbound rules, no client-side daemons in your customers' networks.

What makes it different

Most NAT-traversal tools either (a) skip auth or use a shared secret, or (b) bundle a heavyweight gateway you can't fit on a t4g.nano. swsrs sits in the gap:

  • The party who can mint sessions is gated by your IdP (OIDC, scope-claim).
  • The parties who actually use the tunnel are gated by short-lived per-slot tokens — they need no IdP identity.
  • The server never inspects payloads — it forwards opaque frames. Your app decides the protocol.

See the full comparison →

Try it

bash
# Run the relay locally with auth disabled (dev only)
go run github.com/emdzej/swsrs/cmd/swsrs@latest serve --no-auth --addr :8080

# In another terminal — end-to-end chat over the relay
bash scripts/smoke-chat.sh
# [smoke] PASS

For production: pick an IdP, point --oidc-issuer at it, and your clients run swsrs auth once. Step-by-step setup for Keycloak / Auth0 →

Released under the MIT License.