I built a self-hosted WebRTC SFU with host-safety gates for scale tests
I’ve spent too long guessing why my browser demo wasn’t streaming. The useful answer came from actually running the publisher and viewer. With Hami Media on a loopback server, I opened the streamer and viewer examples in two browser tabs and clicked Go Live . No token was copied into either page or put in the URL: when the optional token field is blank, each page asks the local server for its own…
In a recent test, a self-hosted WebRTC SFU was built with host-safety gates for scalability. Using Hami Media on a loopback server, the streamer and viewer examples were opened in two browser tabs, and "Go Live" was clicked. No tokens were copied into either page or the URL, as each page requests its own short-lived, role-scoped token from the local server when the optional token field is left blank.
The publisher reached a LIVE state, and the server received both audio and video tracks. The viewer rendered video at 1280x720 and received the live audio and video tracks. A chat message sent by the publisher appeared in the viewer, indicating successful communication between the two tabs on the same Mac connected to 127.0.0.1:18082.
This demonstration goes beyond a typical demo, as Hami Media includes host-safety gates that check for swap, memory pressure, and free-disk headroom before starting a run. It also provides measured capacity estimates based on host-specific publisher and viewer recommendations, rather than arbitrary scaling limits. The benchmark protocols and results are committed to the repository, allowing others to inspect the methodology and reproduce the measurements.
To try the local flow, the server must be configured with its HMAC signing key, and the server is started bound to loopback with the appropriate command. The local browser examples handle the short-lived local tokens, but the server still requires authentication setup for remote connections. The test proves the local loopback flow, not remote viewing over the public internet, as the server only advertised loopback-only WebRTC candidates.
The next milestone is to prove a phone on cellular can watch through TURN, but that complete path has not yet been verified end-to-end. The implementation was assisted by AI, but the local browser result was observed directly, and the remote path was not tested.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to