This guide shows you how to run LightNet, an open-source relay you run on a dedicated server on Edgegap and can extend with your own game logic, so players of your host-client Unity game host a match and join it with a room code. The sample works with Mirror, Fish-Networking, PurrNet and Netcode for GameObjects, with one setting to pick the netcode.
Think of it as peer-to-peer, elevated. Out of the box, the relay forwards traffic and the host's game owns the match. Add game logic and it becomes a multi-room dedicated server with relay-like resource efficiency, on the same code and deployment. What changes from day one is where the traffic goes. Every player connects out to your relay, in a location you choose, so nobody opens a port, no player sees another player's IP address, and no shared relay network decides your route.
Once your relay is containerized, Edgegap deploys it from a simple API call, on Edge Cloud for tests or on Private Fleets for a relay that stays up. One relay serves many rooms at once.
This guide covers:
What you need before you start
Connecting your coding agent to Edgegap (optional)
Picking your netcode in the sample
Containerizing the relay and creating an app version
Deploying the relay and connecting players
Grouping players with room codes
Testing with two players
You can do it two ways, and mix them:
With a coding agent: Connected to the Edgegap MCP server and its agent skills, your agent can build and push the relay image, create the app version, deploy it, read its logs and stop it.
By hand: Every step below also works without an agent.
Here, we use Edgegap's LightNet relay sample: the relay, plus Mirror's Tanks game playing through it on all four netcodes.
Which setup fits your game?
An extensible relay is one of six ways to put players in the same match. They differ in who owns the match and where it runs:
Setup | Who owns the match | Best for |
|---|---|---|
A player's device | Local or LAN-style play | |
Shared relay service (Steam, Epic Online Services, Unity Relay) | The host player | A quick fix for connections that fail |
Extensible relay (this guide), on a dedicated server | The host player | Co-op and private rooms among players who trust each other, with your own relay and route; add game logic to grow it into a multi-room game server |
The server | Latency-tolerant games such as RTS, card and turn-based games, with many matches in one central process | |
The server | Matches where fairness matters, each on a fractional vCPU server deployed nearest to its players | |
The server | Full simulations, large matches and anti-cheat |
What an extensible relay gives you:
Players' IP addresses stay hidden: Everyone connects out to the relay, so players never connect to each other directly. That closes the door on attacks on a player's connection, such as flooding the host, that peer-to-peer leaves open.
No port forwarding, no NAT issues: Including on mobile networks, where direct peer-to-peer connections often fail.
Your route, your locations: Deploy the relay where your players are. On free relay services, studios have reported "absolutely no control over how those players are routed" (Live Service Game Summit talk, September 2024).
No shared network: A routing change or outage on another relay network doesn't reach your game.
No rewrite: Your host-client netcode stays as it is, with no relay vendor SDK in your game.
Extend it: You own the relay code, so you can add your own logic: room passwords or player checks, rate limits, kick and ban, room data, telemetry, hooks to your lobby. Shared relay services like Steam's and Epic's don't let you add code.
Grow it into a game server: Add game logic and it becomes a multi-room dedicated server with relay-like resource efficiency, on the same code and deployment.
What it can't do:
Stop cheating out of the box: Whoever holds the match state can change it, and as shipped, the host's game holds it. A cheater ruins the match for everyone, casual or ranked. Server authority stops that: add game logic so the relay holds the match, which means rebuilding your game's rules on the server since the relay only sees raw netcode traffic, or move to a small dedicated server per match. A multi-room server runs in one location, so run one per region: players far from it get worse latency and fairness than players close to it.
Keep the match going when the host leaves: The relay closes the room and disconnects the other players.
Match players or scale on its own: The sample has no matchmaking and no scaling: players share room codes, and you choose where to deploy relays.
Encrypt traffic or check who joins, as shipped: The sample's transports are plain TCP and UDP, and anyone with the relay address and a valid room code can join until you add your own player checks.
Serve browser games: For web games, see Browser Games, Colyseus or Manus AI.
Where it fits:
Main fits: co-op games, mobile games including hybrid-casual, realtime PvP among friends or in private rooms, RTS and card games (TCGs), all without server logic. Other game types may work too.
For co-op specifically, see why co-op casual games need a dedicated game server too.
For a side-by-side of every network model, see authoritative servers, relays and peer-to-peer.
1. Before you start
- A free Edgegap account. Verify your email. No credit card is needed to test.
- Unity 6000.0.54f1 (Unity 6), the version the sample uses. PurrNet needs Unity 2022.3 or newer.
- Docker to build the relay image. Other containerization tools aren't covered here. The .NET 8 SDK is only needed to build the relay outside Docker.
- For the agent path: an Edgegap API token, from Dashboard → User Settings → Tokens. It is organization-wide, so treat it like a password: never put it in your project, your game client or a chat.
Git: Unity needs a Git client (2.14.0 or newer) on your PATH to install packages from a Git URL, such as PurrNet in this sample. macOS usually has one already (Xcode Command Line Tools); on Windows, install Git.
Clone the sample: git clone https://github.com/edgegap/server-sample-lightnet-relay.git
2. Connect your coding agent to Edgegap
Skip this step if you're doing everything by hand.
The Edgegap MCP server lets your agent work on your account: push images, create app versions, deploy, read logs and stop deployments. The skills hold the tested workflow.
Claude Code: install the Edgegap plugin. It adds both the MCP server and the skills, and asks for your API token during install (stored in your system's credential store):
/plugin marketplace add edgegap/llm-agent-skills, then /plugin install edgegap@edgegap. Restart the session.
Only want the MCP server, without the plugin? Run this in your own terminal instead: claude mcp add --transport http edgegap https://mcp.edgegap.dev/mcp -H "Authorization: token YOUR_EDGEGAP_API_TOKEN" --scope user. Don't do both, or you'll have two edgegap servers.
Cursor, VS Code and other clients that send headers: add https://mcp.edgegap.dev/mcp with the header Authorization: token YOUR_EDGEGAP_API_TOKEN, and install the skills with npx skills add edgegap/llm-agent-skills --skill "*".
Claude Desktop: custom connectors can't send the header, so use the local server instead (Node 18+): { "mcpServers": { "edgegap": { "command": "npx", "args": ["-y", "@edgegap/mcp"] } } }. It asks for the token on first use.
Check it works:
List my Edgegap apps.
An empty list is fine. Your agent may also point out that a dedicated server would give your game server authority: that's expected, since a relay leaves the host in charge of the match.
3. Pick your netcode in the sample
Open the tanks/ folder in Unity Hub. The netcode is one field, netcode, in tanks/Assets/Tanks/Resources/TanksSettings.asset: Mirror, FishNet, PurrNet or NGO. The same asset holds the relay address and port. Other ways to switch:
- In the editor: Tanks > Netcode > Mirror / FishNet / PurrNet / NGO sets the asset and opens that netcode's scene.
- In the game: the netcode buttons at the top of the HUD, before hosting or joining.
- From the command line:
-netcode FishNet.
Host and players must use the same netcode. One build contains all four.
| Netcode | Version in the sample | Relay transport |
|---|---|---|
| Mirror | 66.0.9 | MirrorRelayTransport |
| Fish-Networking | 4.7.4 | FishNetRelayTransport |
| PurrNet | 1.24.1 | PurrNetRelayTransport |
| Netcode for GameObjects | 1.13.0 | NgoRelayTransport |
Each transport wraps RelayPeer, the netcode-agnostic relay client in the sample's LightNet package. Reliable messages go over TCP and unreliable ones over UDP, up to 16 KB reliable and 1,177 bytes unreliable per message.
Your own game? Copy the LightNet/ package and the transport for your netcode into your project, and set it as your Network Manager's transport. Your game keeps hosting the match as it does today.
"In my Unity project using {netcode}, add the LightNet package from Edgegap's server-sample-lightnet-relay repository and its {netcode} relay transport. Set it as the Network Manager's transport, read the relay address and port from a settings asset, and add Host and Join room buttons: Host shows the 6-letter room code, Join takes one. Don't change my game logic."
4. Containerize the relay and create an app version
The relay is a .NET 8 console app with its own Dockerfile. Build it from the repository root, for Edgegap's platform, even on Apple Silicon:
docker build --platform linux/amd64 -f relay-server/Dockerfile -t registry.edgegap.com/<project>/lightnet-relay:<tag> .
Test it on your machine first: docker run --rm -p 7777:7777/tcp -p 7777:7777/udp registry.edgegap.com/<project>/lightnet-relay:<tag>. The log should read "LightNet relay listening on TCP 7777, UDP 7777".
Push to the Edgegap Container Registry: run docker login registry.edgegap.com yourself, with the username and token from the Container Registry page, then docker push. Use a new tag for every build, never latest.
Then create the application and its version in the dashboard:
- Your image and tag, with registry credentials (without them, deployments fail with "Unable to pull image from registry").
- One port: 7777, protocol
TCP/UDP, namedgameport. Two separate 7777 TCP and 7777 UDP entries are rejected as duplicates. - Start small on resources: the relay runs no game logic. To size it on real traffic, move off the free tier by adding a credit card (Pay as You Go): it unlocks detailed deployment metrics, so you can see the relay's CPU, memory and network use in a live environment and adjust.
- Optional environment variables:
RELAY_MAX_PEERS(players per relay, default 256) andRELAY_IDLE_EXIT_SECONDS(the relay exits after that many seconds with no room; 0 means never).
With your agent:
"Load the edgegap-containerize skill. Build the LightNet relay from relay-server/Dockerfile at the repository root for linux/amd64, push it to the Edgegap registry with a new tag, then create an Edgegap app and app version for it: one port 7777 with protocol TCP/UDP named gameport, registry credentials set, small resources, restart policy never."
5. Deploy the relay and connect players
Deploy your version from the dashboard (Deploy, pick a location close to your players), or ask your agent:
"Deploy my LightNet relay version near me, wait until it's ready, show me the logs, and give me the host URL and external port."
When the deployment is Ready, players connect to its Host URL (<id>.pr.edgegap.net) and External Port. Edgegap maps TCP and UDP to the same external port, so players pass it once:
- In the sample: set the relay address and port in
TanksSettings.asset, or use-relay <host>.pr.edgegap.net -relayPort <external port>on the command line. - In the relay's log, a peer that connects and leaves right after start is Edgegap's readiness check, not a player.
Keeping relays up:
- Free tier: deployments stop after 60 minutes, which is enough to test.
- Edge Cloud: deployments are meant to be recycled within 24 hours, and you're warned when one runs longer. Edge Cloud also bills egress, and a relay forwards every byte of every match. As such, it may be ideal for on-demand levels of usage, or for development, playtests and pre-production, but at scale, we recommend studios use Private Fleets for greater cost-effectiveness.
- Private Fleets: once your game is live and relays run around the clock, Private Fleets are usually the better fit: reserved hosts in 58 locations worldwide, with 6 TB of egress included per host, enough for almost every game, and persistence settings to decide how long each relay runs.
- Recycling: on any setup, recycling relays regularly is best practice, since a fresh game server is a healthy one (see Edgegap's deployment lifecycle). When, how and how often depends on your game, and the persistence guide covers planning restarts without hurting players. A simple way per region: start a new relay, give its address to players who host new rooms, and stop the old relay once its last room ends.
- Test deployments: make sure to stop them from the dashboard or your agent when you're done, since a deployment bills while it runs.
6. Group players with room codes
The sample groups players with room codes, not a matchmaker:
A player presses Host. The relay creates a room and returns a 6-letter code, shown in the HUD.
The host shares the code: in a party screen, a friends list, a chat or a Discord message.
Other players type the code and press Join room.
Codes skip I and O, so they're easy to read out loud. The room lasts as long as the host stays: when the host leaves, the relay closes the room and disconnects the others. The host can also kick a player.
To bring this into your game, show the code in your own UI and pass it through whatever already connects your players, such as Steam or Epic Online Services friend invites.
When you need matchmaking: Room codes work among friends. For public matches with strangers, casual or ranked, a cheater ruins everyone's fun, so give the match to a server: extend the relay with your game logic, or start with Mirror Networking, Fish-Networking, PurrNet or Netcode for GameObjects, which cover dedicated servers and Edgegap's Matchmaking end to end.
7. Test with two players
- Build the Windows client: Tanks > Build Windows client.
- Start two copies. In the first, press Host and note the room code. In the second, type the code and press Join room.
- Both tanks appear in both games. Drive and fire: the host sees the other tank move and its shots land.
Automated test: With the relay running, ./e2e.sh <host>.pr.edgegap.net <external port> starts a host and a client on each netcode and checks that both games see two tanks, that reliable and unreliable data went through the relay, and that a projectile spawned. Name netcodes to test only some: ./e2e.sh <host>.pr.edgegap.net <external port> FishNet NGO. It runs the Windows build from a Bash shell, such as Git Bash. The sample passed this test on Edgegap on all four netcodes on 29 October 2026.
Stop the deployment when you're done.
Ready for server authority? No host advantage, no cheating host, and the match survives anyone leaving: see the guides for Mirror Networking, Fish-Networking, PurrNet and Netcode for GameObjects. Or extend the LightNet relay with your own game logic. Or extend the LightNet relay with your own game logic. Prefer a managed relay instead of running your own? See Unity Relays.
Stuck? Ask our team and other studios on the Edgegap Discord.
Frequently Asked Questions
Common questions about running an extensible LightNet relay on a dedicated server for a host-client Unity game.
What is LightNet?
LightNet is a lightweight, open-source C# networking library (Apache 2.0) with server and client modes, reliable and unreliable channels, and no built-in game logic. In this sample, it runs as a relay: a .NET console app in a container that forwards traffic between a host player and the others in each room.
Is an extensible relay a dedicated game server?
Not out of the box. It runs on a dedicated server, but as shipped it runs no game logic: the host player's game owns the match, as in peer-to-peer. What it adds over peer-to-peer and shared relay services is your own relay: hidden IP addresses, no port forwarding, a location you choose, and code you can extend. Add game logic to the relay and it becomes a multi-room dedicated server with relay-like resource efficiency.
Does a relay stop cheating?
Not on its own. Whoever holds the match state can change it, and with a relay that's the host's game. A cheater ruins a match for everyone, whether it's casual or ranked. The LightNet relay does stop attacks on players' connections, since nobody sees another player's IP address. Stopping cheating takes server authority: add game logic so the relay holds the match, or use a small dedicated server per match.
Which netcodes does the sample support?
Mirror, Fish-Networking, PurrNet and Netcode for GameObjects, in one Unity 6 build, with one setting to switch. The relay doesn't know which netcode is used: it forwards bytes. Another netcode needs its own transport around the sample's RelayPeer client.
How is this different from Edgegap's Unity Relays?
Unity Relays are Edgegap's managed Distributed Relays: you create a session per match from an API call, and Edgegap picks the relay. With LightNet, you run the relay yourself as an Edgegap deployment, with your own code and room codes, you choose where it runs, and you can extend it with your own logic.
Can I use the LightNet relay for browser games?
Not with the sample as it is: its transports are TCP and UDP, which browsers can't open. For web games, see Browser Games, Colyseus or Manus AI.

Clients
Learn more from clients who integrated Edgegap
31 case studies are available from studios that moved to Edgegap from another platform.

A Flawless Global Launch for Rivals of Aether 2
Aether Studios
Learn how Aether Studios quickly added Edgegap and delivered flawless launch & post-launch to their community.
Case Study

Overcome Latency Introduced by VR’s use of WiFi in Competitive Multiplayer
Halfbrick Studios
Discover how Halfbrick successfully launched & maintains a multiplayer-focused Early Access on META Quest's VR platform.
Case Study

MENA’s Social App Adds Online Games
WOLF
Learn how the highly popular MENA-region social app added matchmaking & multiplayer games orchestration easily to WOLF Qanawat.
Case Study

Hybrid Orchestration Keeps Kickoff Tactics Ready for Any Traffic
Birch Games
How hybrid orchestration helped Birch Games handle traffic, pairing egress-free Fleets with the regionless cloud.
Case Study

7 Days Blood Moons
The Fun Pimps & iLLOGIKA
Learn how Illogika dramatically reduced server costs & ensured the online experience the 7 Days to Die franchise expects.
Case Study

Authentic Online Warfare Requires the Ultimate Orchestration
Highwire Games
Learn how Highwire's need for performance required orchestration only Edgegap can deliver.
Case Study

22,000 Reviews, 4.8 Stars, and Infrastructure That Scaled Automatically
Sinn Studios
How a simple, Slack-supported integration got Sinn Studio's hit VR title online fast and keeps it there.
Case Study

Dynamic Server Orchestration
Under NDA - AAA Studio
Discover how one the world's biggest AAA studio improved its peer-to-peer multiplayer experience through edge computing.
Case Study

Near Zero Latency for AAA Fighting Game
AAA Studio - Under NDA
How an unannounced project delivered the lowest lag possible and improved fairness in its 1v1 game.
Case Study

Play Gods with Multiplayer Physics
Squido Studio
Learn how Squido uses Edgegap's highligh optimized game servers to deliver mind-bending & chaotic VR gameplay.
Case Study

A Fully Managed Solutions that Saves Time for Indies Multiplayer VR Horror
Dirty Pearl Studios
Discover how Dirty Pearl Studios saved development time thanks to Edgegap’s easy integration and automated orchestration alongside its Nakama integration.
Case Study

Instant Global Server Deployment for Collaborative XR Medical Education
AlensiaXR
How AlensiaXR uses Edgegap to deliver low-latency, always-available shared anatomy sessions to medical students worldwide.
Case Study

The Lightkeepers: A VR Social Co-op Game with Dedicated Servers
Spectral Games
How Spectral Games used Edgegap Matchmaking and Server Browser to launch dedicated servers for its VR social lobby, with no prior server experience.
Case Study

Fast & reliable deployments worldwide for PvPvE challenger Gravebound
Crater Studios
How Edgegap’s orchestration and matchmaking helped Crater Studios dramatically helped a small them focus on gameplay instead of infrastructure.
Case Study

Rapid Scaling of Web Metaverse
Hiber
Learn how Hiber eliminated the guesswork out of its server capacity planning with Edgegap.
Case Study

High Hardware Requirements & Custom Game Server Pools
Alderon Games
Learn how Alderon Games instantly leverages a custom pool of game servers across multiple providers worldwide for its popular MMO.
Case Study

Easy Integration for Indie Devs
WhaleFood Games
Read how WhaleFood Games "kicked out" its netcode issues with Edgegap.
Case Study

Cutting-edge tech that powers South-East Asia’s first-ever eSports title.
Anantarupa Studios
Learn how Edgegap transformed South-East Asia’s gaming landscape streamlining complex infrastructure and cutting-edge tech with one seamless solution.
Case Study

One Strike. Global Reach.
Triple Hill Interactive
How Triple Hill Interactive leverages Edgegap's orchestration to deliver low latency and improve fairness in a genre where every millisecond counts.
Case Study

Fast-paced Team Battle Royale... with Gun-totting Animal Plushes!
SANDYFLOOR
Discover how a Korea-based Indie Studio launched it multiplayer worldwide.
Case Study

Mobile Horse Racing Goes Global with Instant, Cost-Efficient Servers
Mirai Labs
How Mirai Labs powers Pegaxy Blaze's worldwide multiplayer races with just-in-time server deployment and fractional vCPU to keep cost per player low.
Case Study

Server Management & Distribution
Matrioshka Games
Read how Matrioshka Games were able to ship a Battle Royale in early access with limited ressources.
Case Study

At my Signal, Unleash Hell!
TyGames
Discover how Indie studio TyGames immerses players in third-person gladiatorial combat multiplayer.
Case Study

Instant Worldwide Orchestration
Soliton Interactive
Discover how Soliton Interactive did the impossible… Ship it's first playable as multiplayer!
Case Study

Competitive play with server-side physics ensures ideal sub-50 ms latency
NS7
Discover why solely Edgegap could enable an indie studio to deliver on its vision for a AAA-quality F2P sports gameplay through server-side physics and authority.
Case Study

Regional Deployments for iGaming
X1 Contra 1
X1 Contra 1 delivers real-time PvP casual games to its Brazilian player base through cost-effective hosting & regional deployments, ensuring data and legal compliance.
Case Study

Pay Only When Players Play: Affordable Multiplayer Infrastructure
Meltdown Interactive
How Edgegap helped indie developer Meltdown Interactive Media solve cost-effective scaling and matchmaking without the complexity, so they could focus on building the game.
Case Study

One Edgegap platform, three very different networking profiles
Warped Games
How Warped Games runs a social hub, real-time co-op, and turn-based co-op, all on the same Edgegap deployment API and the same container pipeline.
Case Study

Pool Live Tour Max
RETA Games
Case Study

Korea’s Web3 POP Extraction Shooter Goes Global, Instantly
NDUS Entertainment
How XOCIETY easily added Edgegap orchestration & integrated custom matchmaking working alongside Edgegap Ping Beacons to optimize latency.
Case Study

Multiplayer in Every Dimension
Arcadia.tv
Discover how Arcadia.tv uses Edgegap's edge network to deliver an innovative, team and location-based athletic VR sport.
Case Study

F2P Mobile Fighter Cuts Infrastructure Costs With Just-in-Time Servers
Game Changers Worldwide
How Game Changer Worldwide hosted Rumble Rush's real-time 3v3 PvP globally on mobile.
Case Study
Key reasons why they chose Edgegap
Discover the impact of Edgegap's automated game server orchestration for a flawless multiplayer experience.









