Skip to main content
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.

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. 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. 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

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.