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.
Questions Fréquemment Posées
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
Découvrez les témoignages de clients qui ont intégré Edgegap
31 études de cas sont disponibles auprès de studios ayant migré d'une autre plateforme vers Edgegap.

Un lancement mondial impeccable pour Rivals of Aether 2
Aether Studios
Découvrez comment Aether Studios a rapidement ajouté Edgegap et a offert un lancement et un post-lancement sans faille à sa communauté.
Case Study

Surmontez la latence introduite par l'utilisation de WiFi par la réalité virtuelle dans les jeux multijoueurs compétitifs.
Halfbrick Studios
Découvrez comment Halfbrick a réussi à lancer et à maintenir un accès anticipé axé sur le multijoueur sur la plateforme VR META Quest.
Case Study

L'application sociale de MENA ajoute des jeux en ligne
WOLF
Découvrez comment l'application sociale très populaire de la région MENA a facilement ajouté des jeux de matchmaking et d'orchestration multijoueur à WOLF Qanawat.
Case Study

L'orchestration hybride maintient Kickoff Tactics prêt pour tout type de trafic
Birch Games
Comment l'orchestration hybride d'Edgegap pour gérer tant le le trafic prévisible et imprévisible, grâce aux flottes "egress-free" et le cloud.
Case Study

Lunes de sang de 7 jours
The Fun Pimps & iLLOGIKA
Découvrez comment Illogika a considérablement réduit ses coûts de serveur et garanti l'expérience en ligne attendue par la franchise 7 Days to Die.
Case Study

La guerre en ligne authentique nécessite l'orchestration ultime
Highwire Games
Découvrez comment le besoin de performance de Highwire nécessite une orchestration que seul Edgegap peut fournir.
Case Study

22 000 avis, 4,8 étoiles et une infrastructure qui s'est adaptée automatiquement
Sinn Studios
Comment une intégration simple, prise en charge par Slack, a permis au titre VR à succès de Sinn Studio d'être mis en ligne rapidement et de s'y maintenir.
Case Study

Orchestration de Serveurs Dynamiques
Under NDA - AAA Studio
Découvrez comment l'un des plus grands studios AAA du monde a amélioré son expérience multijoueur pair à pair grâce à l'informatique en périphérie.
Case Study

Latence presque nulle pour un jeu de combat AAA
AAA Studio - Under NDA
Comment un projet non annoncé a permis d'obtenir le délai d'attente le plus bas possible et d'améliorer l'équité dans son jeu 1v1.
Case Study

Jouez aux dieux avec la physique multiplayer
Squido Studio
Découvrez comment Squido utilise les serveurs de jeu optimisés par Edgegap pour offrir un gameplay VR époustouflant et chaotique.
Case Study

Des solutions entièrement gérées qui font gagner du temps à un jeu VR
Dirty Pearl Studios
Découvrez comment Dirty Pearl Studios a gagné du temps de développement grâce à l'intégration facile d'Edgegap et à l'orchestration automatisée de son intégration avec Nakama.
Case Study

Déploiement instantané de serveurs globaux pour l'éducation médicale en XR
AlensiaXR
Comment AlensiaXR utilise Edgegap pour offrir des sessions d'anatomie partagées à faible latence et toujours disponibles aux étudiants en médecine du monde entier.
Case Study

The Lightkeepers : un jeu coopératif social en VR avec des serveurs dédiés
Spectral Games
Comment Spectral Games a utilisé Edgegap Matchmaking et Server Browser pour lancer des serveurs dédiés pour son salon social VR, sans aucune expérience préalable des serveurs.
Case Study

Déploiements rapides & fiables dans le monde pour le PvPvE Gravebound
Crater Studios
Comment l'orchestration et le matchmaking d'Edgegap ont aidé Crater Studios à se concentrer sur le gameplay plutôt que sur l'infrastructure.
Case Study

Échelle rapide du métavers web
Hiber
Découvrez comment Hiber a éliminé les incertitudes de sa planification de capacité serveur avec Edgegap.
Case Study

Exigences matérielles élevées et pools de serveurs de jeux personnalisés
Alderon Games
Découvrez comment Alderon Games utilise instantanément une pool personnalisée de serveurs de jeux à travers plusieurs fournisseurs dans le monde pour son MMO populaire.
Case Study

Intégration facile pour les développeurs indépendants
WhaleFood Games
Découvrez comment WhaleFood Games a "chassé" ses problèmes de netcode avec Edgegap.
Case Study

Une technologie qui propulse le premier jeu eSports de l'Asie du Sud-Est.
Anantarupa Studios
Découvrez comment Edgegap a transformé le paysage du jeu en Asie du Sud-Est en démocratisant des infrastructures complexes avec sa solution.
Case Study

Une frappe. Portée mondiale.
Triple Hill Interactive
Comment Triple Hill Interactive tire parti de l'orchestration d'Edgegap pour offrir une faible latence et améliorer l'équité dans un genre où chaque milliseconde compte.
Case Study

Un Battle Royale en équipe au rythme effréné... avec des peluches d'animaux armées jusqu'aux dents !
SANDYFLOOR
Découvrez comment un studio indépendant basé en Corée a lancé son jeu multijoueur dans le monde entier.
Case Study

Les courses de chevaux sur mobile disponible mondialement grâce à Edgegap.
Mirai Labs
Comment Mirai Labs propulse les courses multijoueurs mondiales de Pegaxy Blaze grâce au déploiement de serveurs juste-à-temps et au vCPU fractionné pour maintenir un coût bas.
Case Study

Gestion et distribution des serveurs
Matrioshka Games
Lisez comment Matrioshka Games a réussi à expédier un Battle Royale en accès anticipé avec des ressources limitées.
Case Study

À mon signal, déchaînez l'enfer !
TyGames
Découvrez comment le studio indépendant TyGames immerge les joueurs dans un combat multijoueur de gladiateurs à la troisième personne.
Case Study

Orchestration Instantanée Mondiale
Soliton Interactive
Découvrez comment Soliton Interactive a réalisé l'impossible… Livrer son premier jeu jouable en mode multijoueur !
Case Study

Le jeu de hockey avec une physique côté serveur & une latence sous les 50ms
NS7
Découvrez pourquoi seul Edgegap pourrait permettre à un studio indépendant de réaliser sa vision d'un gameplay sportif F2P de qualité AAA grâce à la physique côté serveur et à l'autorité.
Case Study

Déploiements régionaux pour les jeux en ligne
X1 Contra 1
X1 Contra 1 propose des jeux PvP décontractés en temps réel à sa base de joueurs brésilienne grâce à un hébergement économique et à des déploiements régionaux
Case Study

Payez uniquement lorsque les joueurs jouent : une infrastructure abordable
Meltdown Interactive
Comment Edgegap a aidé le développeur indépendant Meltdown Interactive Media à résoudre la mise à l’échelle rentable et le matchmaking sans complexité
Case Study

Une plateforme Edgegap, trois profils réseau très différents
Warped Games
Comment Warped Games gère un hub social, du coopératif en temps réel et du coopératif au tour par tour, le tout sur la même API de déploiement Edgegap et le même pipeline de conteneurs.
Case Study

Pool Live Tour Max
RETA Games
Case Study

Le tireur d'extraction POP Web3 de Corée devient mondial, instantanément
NDUS Entertainment
Comment XOCIETY a facilement ajouté l'orchestration Edgegap et intégré un matchmaking personnalisé en travaillant aux côtés des Edgegap Ping Beacons pour optimiser la latence.
Case Study

Multijoueur dans chaque dimension
Arcadia.tv
Découvrez comment Arcadia.tv utilise le réseau edge d'Edgegap pour offrir un sport VR innovant basé sur l'équipe et la localisation.
Case Study

Un jeu mobile F2P réduit ses coûts d'infrastructure grâce aux serveurs JIT
Game Changers Worldwide
Comment Game Changer Worldwide a hébergé le PvP 3v3 en temps réel de Rumble Rush à l'échelle mondiale sur mobile.
Case Study
Principales raisons pour lesquelles ils ont choisi Edgegap
Découvrez l’impact de l’orchestration automatisée des serveurs de jeu d’Edgegap pour une expérience multijoueur impeccable.









