Whimcall
(2026)
- Real-time communication
- TanStack Start
- WebRTC
- Cloudflare
Video calls that start from a link. A call continues when the network stops or a deploy restarts the server. It finds a media path through strict networks, and moves to a media server when a third person joins.
The problem
A guest opens a link and is in the call, with no account and no app. After that, many problems can occur: the Wi-Fi changes, a deploy restarts the server, a firewall blocks direct media, or a third person joins a call for two.
The call must recover from each of these problems automatically. The same person must not get a second seat, and the screen must not freeze.
My role
I made Whimcall: the product idea, the brand and interface design, the full-stack development, the real-time media architecture and the deployment.
The call
Screenshots of a real call between two people, on a local copy of Whimcall. Each browser used a fake camera that sends a photo from Unsplash.
The signaling connection
Each browser keeps one WebSocket to the Durable Object of its room. The socket carries offers, answers, ICE candidates, presence and media state. Close codes tell the browser to reconnect or to stop.
A. Joining
The browser opens the socket with its session ID and name.
B. Retrying
The first join failed. The browser waits 300 ms (then 900 ms) and tries again.
C. Joined
The room sent its state. The browser sets the reconnect counter to zero.
D. Reconnecting
The socket closed without a leave code. The browser waits 1 s, 2 s, 4 s and then a maximum of 8 s. A random factor from 0.8 to 1.0 changes each wait.
E. Room full
The room has no free seat (close code 4005). The browser shows the limit and does not try again.
F. Could not join
The first join failed three times. The page shows the error.
G. Ended
The person left (4000), the moderator removed the person (4003), or the lobby did not admit the person (4004). The browser does not reconnect.
The media path of a room
The Durable Object of the room records the media path of the room. Two people talk over a direct peer-to-peer connection. When a third person joins, the full room moves to Cloudflare Realtime SFU.
A. Peer to peer
One or two people. Media goes directly between the browsers. It goes through TURN only if ICE cannot find a direct path. Chat and captions use the WebRTC data channel.
B. SFU
Three or more people. Each browser sends its tracks to Cloudflare Realtime SFU. Chat, captions and presence go through the WebSocket of the room.
Recovery of a direct call
In a call for two, the browser monitors the state of its peer connection. After a short interruption, it waits some time for the connection to recover. Then it restarts ICE. Then it makes a new connection.
A. Connected
Media flows. The browser stops all recovery timers.
B. Disconnected
ICE reports an interruption. Many interruptions stop by themselves, so the browser waits 4 s first.
C. Restarting ICE
The browser reconnects signaling and gets new ICE servers. The host sends an ICE-restart offer. The guest asks the host for one.
D. Rebuilding
After 12 s, there is still no media. The browser closes the peer connection and makes a new one.
Signaling stops during a call
The Wi-Fi changes, or a deploy restarts the Worker. All browsers in the room lose their sockets at the same time.
The browser reconnects with exponential backoff, from 1 s to 8 s. A random factor spreads the reconnections of many browsers over time.
Rooms use the WebSocket Hibernation API of Durable Objects. Each socket keeps its session (role, name, mute state and tracks) in its attachment. An idle room can then leave memory and keep its sockets.
The browser keeps its signaling session ID in session storage. When the browser reconnects, the room finds the old socket of that session. The room keeps the role, the admission and the media state, and closes the old socket with code 4001.
In SFU mode, the browser sends its media state, caption state and track metadata again immediately when the new socket opens.
A firewall blocks direct media
Strict NATs and company firewalls block a direct peer-to-peer path. The call then shows no video.
The browser tries STUN first. It uses TURN only if ICE needs it.
The Worker makes Cloudflare Realtime TURN credentials with a time limit.
If this fails, the Worker uses static TURN settings.
Only a browser with an open signaling session can get TURN credentials. Each session gets a maximum of 6, and the edge also limits the rate. Without an open socket in the room, nobody can get credentials.
A direct call loses its media path
The network changes during a call for two. The peer connection goes to “disconnected” or “failed”.
After a short interruption, the browser waits 4 s for the connection to recover. Then, or immediately on “failed”, it restarts ICE with new ICE servers.
If media does not return in 12 s, the browser closes the peer connection and makes a new one. Only one recovery runs at a time.
A call for two becomes a group
A full mesh of direct connections does not scale. Each new person adds one upload for each other person.
When a third admitted person joins, the room records the SFU topology and tells all browsers. Each browser closes its peer connection and sends its media to Cloudflare Realtime SFU.
When the room has two people again, it stays in SFU mode, so the call does not change paths again. It goes back to peer-to-peer only when the last socket closes.
Camera video has three simulcast layers: full, half and quarter size. The speaker on the stage gets the full layer. Grid tiles get the quarter layer. A browser gets video only for the tiles on the screen, and audio only from people who are not muted.
Two devices try to use one seat
A person reconnects, or opens the link on a second device, while the room is full.
The open sockets are the members of the room. A session that has a socket never counts as a new seat.
A full room answers with code 4005. The browser shows the limit and does not try again in a loop.
Free rooms hold 2 people. Rooms of Pro hosts hold a maximum of 100.
Numbers
1 → 8 s — signaling backoff, with 0.8–1.0 jitter
getSignalReconnectDelay in src/components/whimcall/call-reconnect.ts.
4 s · 12 s — wait after an ICE interruption, then a new connection
ICE_DISCONNECTED_GRACE_MS and ICE_RECOVERY_TIMEOUT_MS in src/components/whimcall/call-room.tsx.
6 — TURN credentials for each session
MAX_TURN_CREDENTIALS_PER_SESSION in src/server/room-durable-object.ts.
100 — people in a Pro room
MAX_PEERS_PER_ROOM in src/server/room-protocol.ts.
On a phone
More work
Whimcall is a private repository. Paths are at commit acb7798.