SpawnDev.RTC.Server
2.5.8
Prefix Reserved
See the version list below for details.
dotnet add package SpawnDev.RTC.Server --version 2.5.8
NuGet\Install-Package SpawnDev.RTC.Server -Version 2.5.8
<PackageReference Include="SpawnDev.RTC.Server" Version="2.5.8" />
<PackageVersion Include="SpawnDev.RTC.Server" Version="2.5.8" />
<PackageReference Include="SpawnDev.RTC.Server" />
paket add SpawnDev.RTC.Server --version 2.5.8
#r "nuget: SpawnDev.RTC.Server, 2.5.8"
#:package SpawnDev.RTC.Server@2.5.8
#addin nuget:?package=SpawnDev.RTC.Server&version=2.5.8
#tool nuget:?package=SpawnDev.RTC.Server&version=2.5.8
SpawnDev.RTC.Server
WebRTC signaling server for SpawnDev.RTC consumers. Hosts the WebTorrent tracker wire protocol so any ASP.NET Core app can run a room-based signaling endpoint with a single app.UseRtcSignaling("/announce") call. Bundles an embedded RFC 5766 STUN/TURN server that can run alongside on the same host.
For the client library see SpawnDev.RTC.
What this gives you
Three composable pieces, all opt-in:
| Piece | Method | Purpose |
|---|---|---|
| Signaling tracker | app.UseRtcSignaling("/announce") |
WebSocket endpoint that brokers WebRTC offer/answer between peers. Bit-compatible with the public WebTorrent tracker fleet — your clients (using SpawnDev.RTC, JS WebTorrent, libtorrent v2 with WSS, etc.) just point at your URL instead of wss://tracker.openwebtorrent.com. |
| STUN/TURN server | builder.Services.AddRtcStunTurn(opts => ...) |
Full RFC 5766 TURN with classic long-term creds OR ephemeral HMAC creds (RFC 8489 §9.2 / TURN REST API pattern). Optionally tracker-gated so only currently-announced peers can allocate. Replaces coturn for SpawnDev-style deployments. |
| Origin allowlist | property on the signaling-server options | Browser-side abuse protection: only origins on the allowlist can open a signaling WebSocket. Non-browser clients (desktop C#, curl, Node.js ws) bypass the check automatically because they don't send an Origin header. |
Install
<PackageReference Include="SpawnDev.RTC.Server" Version="1.0.5" />
Or run the standalone host directly: SpawnDev.RTC.ServerApp — single executable, Docker image, env-var configurable. Both the library and the app share the same internals; pick whichever suits your deployment.
Quickstart — embedded signaling
using SpawnDev.RTC.Server.Extensions;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseWebSockets();
app.UseRtcSignaling("/announce"); // your tracker is now live
app.Run();
Every WebTorrent-compatible client can now use wss://your-host/announce as a tracker URL. Peers in the same infohash room get paired automatically.
Quickstart — embedded STUN/TURN
Add it during service registration, separate from signaling. Both can run in the same host process:
using SpawnDev.RTC.Server.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRtcStunTurn(opts =>
{
opts.Enabled = true;
opts.ListenAddress = "0.0.0.0";
opts.Port = 3478; // standard STUN/TURN port
opts.Realm = "your-domain.example";
// Long-term credentials (classic TURN auth)
opts.LongTermUsername = "alice";
opts.LongTermPassword = "alice-secret";
// OR ephemeral REST API credentials (preferred for production)
opts.EphemeralSharedSecret = "your-32-byte-shared-secret-here";
opts.EphemeralLifetime = TimeSpan.FromHours(1);
// OR tracker-gated ephemeral: only peers currently announced to your
// tracker can allocate. Combine with the signaling layer above.
opts.TrackerGated = true;
opts.RelayPortRangeStart = 49152; // for NAT port forwarding
opts.RelayPortRangeEnd = 65535;
});
var app = builder.Build();
app.UseWebSockets();
app.UseRtcSignaling("/announce");
app.Run();
Or bind from appsettings.json:
builder.Services.AddRtcStunTurn(builder.Configuration.GetSection("Turn"));
{
"Turn": {
"Enabled": true,
"Port": 3478,
"Realm": "your-domain.example",
"EphemeralSharedSecret": "your-32-byte-shared-secret-here"
}
}
Full options + walkthrough at Docs/stun-turn-server.md in the parent repo.
Origin allowlist
Browsers send an Origin header on every WebSocket connection. Setting AllowedOrigins rejects browser connections from origins not on the list — useful for keeping a tracker private to your own apps without firewalling the port:
app.UseRtcSignaling("/announce", opts =>
{
opts.AllowedOrigins = new[] { "https://app.example.com", "https://staging.example.com" };
});
Desktop / CLI clients (SpawnDev.RTC desktop, JS WebTorrent on Node, curl) don't send Origin; the allowlist auto-bypasses them so non-browser clients keep working. Locked by OriginAllowlist_E2E_MissingOriginBypassesList in the RTC test suite.
What's in the package
TrackerSignalingServer— the signaling endpoint. Speaks the same wire protocol astracker.openwebtorrent.com(JSONannounce/offer/answer/signalmessages over WebSocket). Per-room pairing keyed on info_hash.StunTurnServerHostedService— the embedded TURN server, registered as anIHostedServiceso the lifetime is managed by ASP.NET Core's host. Built on the bundled SipSorcery fork.EphemeralTurnCredentials— utility for issuing/validating ephemeral usernames + HMAC passwords. Pair withTurnServerConfig.ResolveHmacKeyfor tenant-aware credential rotation.UseRtcSignaling/AddRtcStunTurnextension methods onIApplicationBuilder/IServiceCollection.
Production deployments
hub.spawndev.com:44365 runs this exact stack. Real-world load: dozens of concurrent rooms, simultaneous TURN allocations, browser + desktop clients pairing through it daily.
For the standalone-executable + Docker route, see the SpawnDev.RTC.ServerApp project — same library, env-var-driven configuration, single deployable artifact.
Dependencies
SpawnDev.RTC1.1.6 (signaling client primitives, room key types)- ASP.NET Core 10 (
Microsoft.AspNetCore.Appframework reference) - SipSorcery fork (bundled inline via SpawnDev.RTC) — for the TURN server's underlying RFC 5766 implementation
Documentation
| Topic | Doc |
|---|---|
| Signaling protocol overview | Docs/signaling-overview.md |
| Running a tracker (this library) | Docs/run-a-tracker.md |
| STUN/TURN server reference | Docs/stun-turn-server.md |
License
MIT — see LICENSE.txt in the parent repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- SpawnDev.RTC (>= 2.5.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.5.12 | 64 | 12/1/2026 |
| 2.5.11 | 83 | 12/1/2026 |
| 2.5.10 | 57 | 12/1/2026 |
| 2.5.9 | 54 | 12/1/2026 |
| 2.5.8 | 53 | 12/1/2026 |
| 2.5.7 | 51 | 12/1/2026 |
| 2.5.6 | 54 | 12/1/2026 |
| 2.5.5 | 57 | 12/1/2026 |
| 2.5.4 | 49 | 12/1/2026 |
| 2.5.3 | 96 | 11/30/2026 |
| 2.5.2 | 99 | 11/30/2026 |
| 2.5.0 | 100 | 11/29/2026 |
| 2.4.0 | 128 | 11/4/2026 |
| 2.3.0 | 169 | 10/1/2026 |
| 2.2.4 | 149 | 9/14/2026 |
| 2.2.3 | 139 | 9/8/2026 |
| 2.2.2 | 136 | 8/18/2026 |
| 2.2.1 | 131 | 8/18/2026 |
| 2.1.1 | 136 | 8/18/2026 |
| 2.1.0 | 125 | 8/17/2026 |
v2.5.8 - On SpawnDev.SIPSorcery 10.0.17: two peers relayed by the same TURN server reach each other without UDP hairpinning on the server's NAT (data between its own allocations is delivered internally). v2.5.7 - Ships with SpawnDev.RTC 2.5.7 (tracker client fixes); no server change. v2.5.6 - On SpawnDev.SIPSorcery 10.0.16. The TURN server now authenticates Refresh, CreatePermission and ChannelBind, so TrackerGatedResolver also ends existing relays: once a peer leaves the tracker, its relay can no longer be refreshed. A Refresh lifetime is capped at TurnServerConfig.MaxLifetimeSeconds (3600 s default). v2.5.5 - The tracker issues TURN credentials: TrackerServerOptions.TurnCredentials answers {"action":"turn_credentials"} on a peer's own announce socket, for that socket's announced peer id only (EphemeralTurnCredentials.Issuer). TrackerGatedResolver also accepts the peer id in hex (UserIdForPeer), since a raw 20-byte peer id cannot be a username's userId. Additive. v2.5.4 - SpawnDev.RTC 2.5.4. v2.5.3 - SpawnDev.RTC 2.5.3 (desktop data channel latency and throughput fix). v2.5.2 - SpawnDev.RTC 2.5.2 (re-announces keep established connections). v2.5.0 - SpawnDev.RTC 2.5.0 (DTLS fingerprint API, tracker socket options, remote channel close). v2.3.0 - SpawnDev.RTC 2.3.0 (SpawnDev.SpawnJS 3.0.0).