Skip to main content

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.

A session is one viewer connected to your stream. This page is the reference for what state a session is in at any moment, what happens when all your workers are busy, how AFK timeouts work, and how to handle disconnects.

Session states

The Web SDK exposes the session’s current state. Use it to drive your loading UI, queue position, and reconnect messaging.
StateMeaning
requestingBrowser is connecting to Streampixel.
queuedNo worker free; the viewer is waiting in line.
connectingWorker assigned; stream is being set up.
streamingStream is live; video and audio flowing.
idleViewer has been inactive past the AFK warning threshold.
disconnectedSession ended cleanly.
failedSession ended unexpectedly (network drop, app crashed, no worker).

Queue system

When every worker in your project’s region is busy, new viewers wait in a queue. The Web SDK fires events with the viewer’s position so you can render a wait UI.
1

Viewer opens your stream

Session starts in requesting, then moves to queued if no worker is free.
2

Position updates flow to your UI

The Web SDK fires events whenever the viewer’s position improves. Show a queue UI with the current position.
3

Slot opens

The first viewer in line is promoted to connecting, and a worker is reserved for them.
Increase your project’s worker count to reduce queueing during peak traffic. See configuring your project.

AFK timeout

To free workers from idle viewers, Streampixel tracks the time since the viewer’s last input. After a configurable threshold the viewer sees a warning; if they don’t interact, the session ends.
SettingDefaultNotes
Warning timeout2 minutes of inactivityWarning UI appears in the SDK.
Disconnect timeout30 seconds after warningSession ends with an AFK disconnect.
Both thresholds are configurable from project settings or the Web SDK init options. Disable AFK only if you have a clear reason — idle sessions hold an entire GPU worker.

Disconnect codes

Sessions end with a code that tells you whether the disconnect was normal, the viewer’s choice, or a problem on your build/server.
CodeMeaning
1000Normal closure.
1001Going away (tab closed, browser quit).
1006Abnormal closure (network drop, no close frame).
4000Project disabled.
4001No worker available.
4002App not found.
4003App unable to launch.
4004Max runtime reached.
4005Streamer not found.
4006App crashed.
4007Reconnection failed.
Full reference and how to recover from each: disconnect codes.

Reconnection

The Web SDK has built-in reconnection for transient failures. On 1006 and 4007, the SDK retries with exponential backoff until the viewer 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 be on a fresh worker, depending on availability.
For app-level codes (40004006), reconnection alone won’t fix the problem. Surface a meaningful error to the viewer and, where appropriate, link to a status page or a “try again” button.

What ends a session

TriggerCode(s)Notes
Viewer closes tab1001Normal end-of-session.
Network drop1006SDK reconnects automatically.
AFK timeout4004Configurable threshold.
All workers busy at start4001Viewer never reached streaming.
App crashed4006Build-side problem; check UE logs.
Project disabled4000Owner 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.

Configuring your project

Tune worker count, AFK timeouts, and more.

Codec settings

Pick the right codec for your audience and content.