Framework-agnostic python-socketio relay for live rrweb session mirroring (record -> fan-out -> replay).
Project description
rrweb-relay
A framework-agnostic python-socketio relay for live rrweb session mirroring. It receives rrweb events from publishers, keeps a per-session in-memory buffer (with periodic full-snapshot checkpoints), and fans events out to watchers over socket.io rooms. It never touches a database and imports no web framework.
Pairs with the @rrweb-live/sdk browser SDK. Runs standalone (any backend
stack can run it alongside) or mounted into any ASGI app (Django/FastAPI/Starlette).
Install
pip install rrweb-relay # core (python-socketio + pyjwt)
pip install "rrweb-relay[standalone]" # + uvicorn + python-dotenv (for `python -m rrweb_relay`)
pip install "rrweb-relay[introspection]"# + httpx (for the HTTP-introspection verifier)
Auth is pluggable
The only thing a host must provide is a TokenVerifier: verify(token) -> Claims | None (sync or
async). Built-ins:
SharedSecretJWTVerifier— verify an HS256 JWT with a shared secret + configurableClaimMap(which claims map touser_id/email/role) and optionalrequire_token_type.HTTPIntrospectionVerifier— POST the token to an endpoint on your backend that returns claims (lets Node/Rails/Go/... plug in their own auth).
Roles are policy: RolePolicy(publish_roles, watch_roles) decides who may record vs observe
(empty set = any authenticated role). Preset DJANGO_CUSTOMER_ADMIN = customers publish, admins watch.
Mount into an existing ASGI app
from rrweb_relay import Relay, RelayConfig, SharedSecretJWTVerifier, ClaimMap, DJANGO_CUSTOMER_ADMIN
relay = Relay(RelayConfig(
verifier=SharedSecretJWTVerifier(secret=SECRET, claim_map=ClaimMap(), require_token_type="access"),
socketio_path="socket.io",
role_policy=DJANGO_CUSTOMER_ADMIN,
))
application = relay.asgi_app(other_asgi_app=your_django_or_fastapi_asgi_app)
Run standalone
cp .env.example .env # set RELAY_JWT_SECRET to your issuer's signing secret
python -m rrweb_relay # serves socket.io on RELAY_HOST:RELAY_PORT
Point the browser SDK's socket at this origin (directly, or via your reverse proxy's /socket.io).
Wire protocol v1
C→S: tracker:start, tracker:events, admin:hello, admin:watch, admin:unwatch.
S→C: sessions, watch:init, live:events, live:end. Handshake auth: { token }.
Scaling note
State is an in-process dict + socket.io's default in-memory manager → single worker only.
Horizontal scaling needs a socket.io client_manager (Redis) + a shared registry. Not included.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rrweb_relay-0.1.0.tar.gz.
File metadata
- Download URL: rrweb_relay-0.1.0.tar.gz
- Upload date:
- Size: 42.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35102779ca9f9725b6eeb69db10fef371c27414f4d1952ccf4d4bd5650ac211c
|
|
| MD5 |
f02d850442951d847eb2a2183db8607e
|
|
| BLAKE2b-256 |
f3d08d93dda76430e654d9d413edc5b2f60d67b22d4e0a2d42e00f5325e62b62
|
File details
Details for the file rrweb_relay-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rrweb_relay-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dd483bf1dfc79986c6eb698ebcdb1901b68cb9d0b3fcf66ff66e9a2b4330c33
|
|
| MD5 |
eb9725f36de5a70bf57667306a31138f
|
|
| BLAKE2b-256 |
4c59614ca6ee61af94c874cecdf01220219e3a50055898ddcb16daa214678b5f
|