A session is one user connected to one streaming worker over a single WebRTC peer connection. It begins when the browser opens a WebSocket to signalling and ends when either side closes the connection. This page walks through the states a session moves through, what queueing and AFK timeouts do, and how to handle disconnects.Documentation Index
Fetch the complete documentation index at: https://docs.streampixel.io/llms.txt
Use this file to discover all available pages before exploring further.
End-to-end flow
Session states
The Web SDK exposes the session’s current state. Use it to drive your loading UI, queue position display, and reconnection messaging.| State | Meaning |
|---|---|
requesting | Browser is opening the WebSocket to signalling. |
queued | No worker free; user is waiting in the project’s queue. |
connecting | Worker assigned; WebRTC handshake (SDP + ICE) in progress. |
streaming | Peer connection open; video and audio flowing. |
idle | User has been inactive past the AFK warning threshold. |
disconnected | Session ended cleanly (user, server, or AFK timeout). |
failed | Session ended unexpectedly (e.g. 1006, app crashed, no worker available). |
Queue system
When every worker in your project’s region is busy, new sessions enter a queue. The signalling server emits the user’s position so you can render a wait UI.Position updates flow to the SDK
The Web SDK fires events whenever your position improves. Show a queue UI with the current position.
AFK timeout
To free workers from idle users, Streampixel tracks the time since the last input event. After a configurable threshold the user sees a warning; if they don’t interact, the session is disconnected.| Setting | Default | Notes |
|---|---|---|
| Warning timeout | 2 minutes of inactivity | Warning UI appears in the SDK. |
| Disconnect timeout | 30 seconds after warning | Session ends with an AFK disconnect. |
Disconnect codes
Sessions end with a code that tells you whether the disconnect was normal, the user’s fault, or an app/server problem.| Code | Meaning |
|---|---|
1000 | Normal closure. |
1001 | Going away (tab closed, browser quit). |
1006 | Abnormal closure (network drop, no close frame). |
4000 | Project disabled. |
4001 | No worker available. |
4002 | App not found. |
4003 | App unable to launch. |
4004 | Max runtime reached. |
4005 | Streamer not found. |
4006 | App crashed. |
4007 | Reconnection failed. |
Reconnection
The Web SDK has built-in reconnection for transient failures. On1006 and 4007, the SDK retries with exponential backoff until the user gives up or a connection succeeds. You can hook into reconnection events to render your own UI.
Reconnection is not guaranteed to land on the same worker — the new session may even land on a fresh worker, depending on availability.
4000–4006), reconnection alone won’t fix the problem. Surface a meaningful error to the user and, where appropriate, link to a status page or a “try again” CTA.
What ends a session
| Trigger | Code(s) | Notes |
|---|---|---|
| User closes tab | 1001 | Normal end-of-session. |
| Network drop | 1006 | SDK reconnects automatically. |
| AFK timeout | 4004 | Configurable threshold. |
| Worker pool exhausted at start | 4001 | User never reached streaming. |
| App crashed | 4006 | Build-side problem; check UE logs. |
| Project disabled | 4000 | Owner disabled the project from the dashboard. |
Next steps
Disconnect codes
Full code reference and recovery patterns.
Web SDK overview
Hook into session events from your frontend.
Streaming basics
What’s flowing across the open peer connection.
How Streampixel works
Where signalling and workers fit in the architecture.