<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Niroj Paudyal</title>
    <description>The latest articles on DEV Community by Niroj Paudyal (@kneerose).</description>
    <link>https://dev.to/kneerose</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4271291%2F5d2176d7-f6c9-4a36-8675-428de286ce2f.png</url>
      <title>DEV Community: Niroj Paudyal</title>
      <link>https://dev.to/kneerose</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kneerose"/>
    <language>en</language>
    <item>
      <title>I built a self-hosted WebRTC SFU with host-safety gates for scale tests</title>
      <dc:creator>Niroj Paudyal</dc:creator>
      <pubDate>Sat, 28 Nov 2026 19:59:27 +0000</pubDate>
      <link>https://dev.to/kneerose/i-built-a-self-hosted-webrtc-sfu-with-host-safety-gates-for-scale-tests-258l</link>
      <guid>https://dev.to/kneerose/i-built-a-self-hosted-webrtc-sfu-with-host-safety-gates-for-scale-tests-258l</guid>
      <description>&lt;p&gt;I’ve spent too long guessing why my browser demo wasn’t streaming. The useful answer came from actually running the publisher and viewer.&lt;/p&gt;

&lt;p&gt;With Hami Media on a loopback server, I opened the streamer and viewer examples in two browser tabs and clicked &lt;strong&gt;Go Live&lt;/strong&gt;. 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 short-lived, role-scoped token.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I verified
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The publisher reached &lt;strong&gt;LIVE&lt;/strong&gt;, and the server received audio and video tracks.&lt;/li&gt;
&lt;li&gt;The viewer rendered video at &lt;strong&gt;1280×720&lt;/strong&gt; and received live audio and video tracks.&lt;/li&gt;
&lt;li&gt;A chat message sent by the publisher appeared in the viewer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was two tabs on one Mac, connected to &lt;code&gt;127.0.0.1:18082&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this is more than a demo
&lt;/h2&gt;

&lt;p&gt;Hami Media is a single-binary WebRTC SFU. Beyond the loopback browser flow verified above, it includes several pieces of engineering work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Host-safety gates for scale-proof runs.&lt;/strong&gt; The &lt;code&gt;sfu-single&lt;/code&gt; and &lt;code&gt;m9h&lt;/code&gt; modes check used swap, memory pressure, and free-disk headroom before starting; a watchdog monitors these runs. This gate does not currently apply to every mode, including &lt;code&gt;serve&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measured capacity estimates.&lt;/strong&gt; &lt;code&gt;./hami-media capacity&lt;/code&gt; reports host-specific publisher/viewer recommendations scaled from measured anchors, not beyond them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reproducible benchmarks.&lt;/strong&gt; Benchmark protocols are preregistered and run artifacts are committed, so readers can inspect the methodology and reproduce reported measurements.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/kn33r0s3/hami-media" rel="noopener noreferrer"&gt;github.com/kn33r0s3/hami-media&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Try the local flow
&lt;/h2&gt;

&lt;p&gt;The server still needs its HMAC signing key configured. “No token copy-paste” means the browser examples handle their short-lived local tokens for you; it does not mean the server has no authentication setup.&lt;/p&gt;

&lt;p&gt;Build Hami Media and start it bound to loopback:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go build -o hami-media .
&lt;span class="nv"&gt;HAMI_SFU_HMAC_KEY_FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/path/to/hami.key ./hami-media -mode=serve -serve-listen=127.0.0.1:18082
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open &lt;code&gt;http://127.0.0.1:18082/examples/streamer.html&lt;/code&gt;, click &lt;strong&gt;Go Live&lt;/strong&gt;, and open &lt;code&gt;http://127.0.0.1:18082/examples/viewer.html&lt;/code&gt; in another tab and click &lt;strong&gt;Watch Room&lt;/strong&gt;. The local token-minting route is restricted to loopback and same-origin requests. Remote servers still require a supplied token.&lt;/p&gt;

&lt;h2&gt;
  
  
  The limit
&lt;/h2&gt;

&lt;p&gt;This test proves the local loopback flow, not remote viewing over the public internet: this test server advertised loopback-only WebRTC candidates, and an HTTPS tunnel does not carry media. The next milestone is proving a phone on cellular can watch through TURN; that complete path is not yet verified end-to-end.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/kn33r0s3/hami-media" rel="noopener noreferrer"&gt;Hami Media on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI disclosure: Copilot assisted with implementation, browser verification, and this draft. The local browser result was observed; the remote path was not tested.&lt;/p&gt;

</description>
      <category>webrtc</category>
      <category>go</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
