Discover how Edgegap works

Discover how Edgegap works

/

/

SpaceEdge (WebGL)

Fish-Networking

SpaceEdge (WebGL)

Deploy to Edgegap

Published

Published

Published

SpaceEdge (WebGL): Run Edgegap's FishNet space shooter on Edgegap dedicated servers, with Matchmaking

SpaceEdge (WebGL): Run Edgegap's FishNet space shooter on Edgegap dedicated servers, with Matchmaking

SpaceEdge is Edgegap's space shooter sample for Fish-Networking (FishNet), built in Unity. This version runs in the browser: players fly, shoot and score in Unity WebGL, and every match runs on its own Edgegap dedicated game server.

The game code stays FishNet: the same NetworkManager, Bayou transport, prediction and RPCs. The sample adds a few Edgegap scripts around it: one starts the server, one finds a match, one keeps them alive across scene changes.

No player hosts the match. The dedicated server checks every shot, owns health and score, and stops its own deployment when everyone has left. The game client holds no Edgegap API token.

Edgegap's network spans 615+ Edge Cloud locations (learn more). Each server is deployed to the best available location for its players and billed only while the match runs.

Platforms: Unity WebGL in the browser, over secure WebSockets (wss://); Linux dedicated server. The README says Windows desktop builds also work through Bayou (not part of the tested run). Unity 2021.3.45f2, FishNet 4.1.6R. Uses free Unity Asset Store assets (Cartoon FX, Sci-Fi Sfx, Star Sparrow, Starfield Skybox, TotalJSON) under their own licences.

How it works

  1. A player opens the game in the browser and selects Start Game.

  2. Direct mode (default): the client connects to the server address and port set on MatchmakingSystem. Matchmaker mode (opt-in): the client sends a ticket to the Edgegap Matchmaker, which groups 2 to 4 players and starts an Edgegap server near them.

  3. The server starts FishNet on 0.0.0.0:7770 over plain WebSockets. Edgegap's TLS Upgrade adds the secure layer, so browsers connect with wss:// to the deployment's host name. No certificate to buy.

  4. Players fly and shoot in BattleScene. The server checks each shot and owns health and score.

  5. When nobody joins within 120 seconds, or 30 seconds after the last player leaves, the server stops its own deployment, and billing stops.

What the sample changed:

Path

What it does

Assets/SpaceEdge/Scripts/Systems/MatchmakingSystem.cs

Connects Start Game to a direct connection (default) or to the matchmaking client. With the matchmaker off, it disables the matchmaking client.

Assets/Edgegap/EdgegapMatchmakingClient.cs

Matchmaker mode: creates a ticket, waits for HOST_ASSIGNED, then connects with wss://{fqdn}:{external port}. Latency beacons are off in WebGL.

Assets/Edgegap/EdgegapServerLifecycle.cs

Server builds: starts the FishNet server on port 7770, reads Edgegap's injected variables, and stops the deployment when it's empty. Replaces FishNet's Start On Headless.

Assets/Edgegap/EdgegapPersistence.cs

Keeps the Edgegap object alive across MainMenu → BattleScene → MainMenu.

Assets/Edgegap/Editor/

Command-line Linux server and client builds, plus scene setup.

Packages/manifest.json

Edgegap Unity SDK as a Git package (main), not an embedded copy.

Dockerfile, matchmaker-config.json

Server image on Ubuntu 22.04 with CA certificates; matchmaker profile for browsers.

No credit card required. Free tier includes the resources to deploy a real game server.

No credit card required. Free tier includes the resources to deploy a real game server.

Two spaceships flying over a glowing hexagon grid in FishNet's SpaceEdge sample, built for WebGL.

SpaceEdge in the browser: every ship flies on the same Edgegap dedicated server.

Step-by-Step Guide

Run the Sample

1. Before you start

  • A free Edgegap account. Verify your email. No credit card is needed to test.

  • Unity 2021.3.45f2 with the Linux Build Support (Mono), Linux Dedicated Server Build Support and WebGL Build Support modules.

  • Docker Desktop, installed and running.

  • Python 3, or any static web server, to serve the WebGL build locally.

  • Clone the repository with git clone, then open the Fishnet_v4.1.6R_WebGL_Matchmaker folder in Unity Hub. The other folders are older samples; some put an Edgegap API token in the game client, so use them for local tests only.

Git: Unity needs a Git client (2.14.0 or newer) on your PATH to install packages from a Git URL, such as the Edgegap plugin. macOS usually has one already (Xcode Command Line Tools); on Windows, install Git.

2. Play locally

Build the server with Tools → Edgegap → Build Linux Dedicated Server. The build goes to Builds/EdgegapServer/. Then run it in Docker, from the sample folder:

docker build --platform linux/amd64 -t fishnet-server:local .

docker run --rm -p 7770:7770 fishnet-server:local

The log shows Edgegap Server | Starting server on 0.0.0.0:7770. and Not running on Edgegap, self-stop disabled.

Build the WebGL client from File → Build Settings, or from the command line:

Unity -batchmode -quit -projectPath . -executeMethod EdgegapServerBuild.BuildClient -edgegapClientTarget webgl

Serve Builds/Client/webgl, for example with python -m http.server 8080, open http://localhost:8080 in two tabs and select Start Game in each. The defaults (localhost, 7770, Direct Use Wss off) connect to the local server.

3. Put the game server on Edgegap

Push the image to your Edgegap registry. The Container Registry page has your project, username and token:

docker login registry.edgegap.com

docker build --platform linux/amd64 -t registry.edgegap.com/<project>/fishnet-server:v1 .

docker push registry.edgegap.com/<project>/fishnet-server:v1

In the dashboard, create an application (the sample's matchmaker config expects fishnet-webgl-matchmaker) and a version v1 for that image:

  • Port: name gameport, port 7770, protocol WS, TLS Upgrade on. Edgegap handles TLS, so browsers connect with wss:// while the server speaks plain ws.

  • Container registry username and token set, or deployments fail to pull the image.

Use a new image tag for every build, never latest.

4. Play on an Edgegap server

Deploy the version from the dashboard, near you. When it's Ready:

  1. On the MatchmakingSystem object in the MainMenu scene, set Direct Address to the deployment's host name (<id>.pr.edgegap.net, not its IP), Direct Port to its external port, and tick Direct Use Wss.

  2. Rebuild the WebGL client, serve it, and play in two tabs.

The external port changes on every deployment, so read it each time. The server stops its deployment 120 seconds after it starts if nobody joins, and 30 seconds after the last player leaves.

5. Add it to your own FishNet game

The sample is a working reference: your coding agent can copy its tested files instead of writing them from scratch. Four changes make a FishNet browser game run on Edgegap:

  1. The server starts itself. Assets/Edgegap/EdgegapServerLifecycle.cs starts FishNet on a fixed port in server builds. Turn Start On Headless off on ServerManager, so the same scene works for client and server builds.

  2. The server stops itself. The same script reads Edgegap's injected variables and stops the deployment when it's empty, so billing stops.

  3. It survives scene changes. Assets/Edgegap/EdgegapPersistence.cs keeps the Edgegap object alive across FishNet scene loads. Without it, the server's self-stop dies with the menu scene.

  4. Browsers connect securely. Bayou on 7770, a WS port with TLS Upgrade on the app version, and clients that connect with wss:// to the host name (MatchmakingSystem.cs, EdgegapMatchmakingClient.cs).

Then containerize the server with the sample's Dockerfile as a model, and create the app version as in step 3.

With your agent:

"Load the edgegap skill, then edgegap-fishnet. Using github.com/edgegap/netcode-game-sample-unity-fishnet-hashgrid/tree/main/Fishnet_v4.1.6R_WebGL_Matchmaker as the reference, make my FishNet game a WebGL dedicated-server game: Bayou on 7770, the Edgegap server lifecycle, persistence and matchmaking client scripts, Start On Headless off, wss to the host name on the client, and a matchmaker config with no latency rule and my web origins in allowed_cors_origins."

For each step in detail, by hand, see the Fish-Networking integration guide. For browser rules that apply to any Unity netcode, see Unity WebGL.

6. Turn on the Edgegap Matchmaker

The matchmaker groups players, starts an Edgegap server near them and gives every client its address. In the sample it's off until you tick it.

  1. In matchmaker-config.json, set application.name and version to your app and version, and list every web address that serves your WebGL build in allowed_cors_origins (the file has http://localhost:8080).

  2. In the dashboard, open Matchmaker, select Create Matchmaker, upload the file and select Create and Start.

  3. In MainMenu, copy the API URL and Auth Token into Base Url and Auth Token on the Edgegap object's Edgegap Matchmaking Client. The Auth Token is safe to ship in the client. Tick Use Edgegap Matchmaker on MatchmakingSystem.

  4. Rebuild the client, serve it from an allowed origin, open two tabs and select Start Game in both.

Two rules for browser games, already in the sample's config:

  • No latency rule. Browsers can't ping Edgegap's latency beacons, so Edgegap places the server from the players' IPs.

  • List your origins. Without them in allowed_cors_origins, the browser blocks the matchmaker's replies.

The casual profile matches 2 to 4 players. When you ship a new server build, push a new tag, create a new app version, then in the matchmaker Stop → Edit application.version → Start.

Known limits

  • Test with two players. The profile expands to 1 player after 30 seconds, but in Edgegap's tests a lone player only got a server when the ticket neared its 5-minute expiration.

  • Free tier. The matchmaker restarts every 3 hours (URL and token stay the same), and only one deployment runs at a time. A forgotten test deployment blocks matchmaking.

  • No ticket check on the server yet. The server doesn't check that a connecting client holds one of the match's tickets (MM_TICKET_IDS), and there's no backfill. Both are next steps for a real game.

  • Direct mode is manual. Without the matchmaker, you copy each deployment's host name and port into the client and rebuild.

What was tested

Tested end to end on Edgegap on 15 October 2026, with Unity 2021.3.45f2, FishNet 4.1.6R, Bayou, Edgegap Unity SDK 3.5.5 with the POST fix that shipped in 3.5.6, and matchmaker 3.3.2 on the free tier:

  • Matchmaker: two WebGL tabs were matched, got the same server, connected over wss:// with TLS Upgrade, and played.

  • Self-stop: after the match, the server stopped its own deployment.

  • Local: the Docker server logs Starting server on 0.0.0.0:7770. and accepts WebGL clients on localhost.

On 21 October 2026 the sample moved to the SDK's main branch (3.5.6 or later), which carries the same fix. Desktop clients through Bayou: should work, not part of the tested run.

Frequently Asked Questions

Questions about running FishNet's SpaceEdge sample in the browser on Edgegap.

Can a FishNet WebGL game connect to a dedicated server?

Yes, with the Bayou WebSocket transport. The server runs plain WebSockets on port 7770, Edgegap's TLS Upgrade adds the secure layer, and the browser connects with wss:// to the deployment's host name. SpaceEdge does exactly this.

Do I need the Edgegap Matchmaker to play SpaceEdge online?

No. By default the sample connects directly to a server address and port you set, so you can test against a deployment you start from the dashboard. Tick Use Edgegap Matchmaker to have players grouped and connected automatically.

Does the SpaceEdge client hold an Edgegap API token?

No. In matchmaker mode it only uses the matchmaker's Auth Token, which is safe to ship in clients. The older folders in the same repository call the Edgegap API from the client, so use those for local tests only.

Why does the matchmaker fail on Unity 2021.3?

Before Unity 2022.3, Edgegap Unity SDK 3.5.5 and older send ticket JSON the matchmaker rejects with HTTP 400. Use SDK 3.5.6 or later; the sample tracks the SDK's main branch.

Clients

Learn more from clients who integrated Edgegap

31 case studies are available from studios that moved to Edgegap from another platform.

Key reasons why they chose Edgegap

Discover the impact of Edgegap's automated game server orchestration for a flawless multiplayer experience.

Cost

Pricing

Pricing

Optimize costs and performance with hybrid orchestration

Optimize costs and performance with hybrid orchestration

Optimize costs and performance with hybrid orchestration

Edge Cloud

On-Demand

$0.00115

/ vCPU

/ MINUTE

Billed by the Minute, Only on Usage

Pay only when players play. 0 active servers = $0

Deploy game servers worldwide, per instance, to all 615+ edge cloud locations. Zero commitment.

Simply add a credit card.

Edge Cloud

On-Demand

$0.00115

/ vCPU

/ MINUTE

Billed by the Minute, Only on Usage

Pay only when players play. 0 active servers = $0

Deploy game servers worldwide, per instance, to all 615+ edge cloud locations. Zero commitment.

Simply add a credit card.

Private Fleet (Bare Metal)

Reserved Capacity

$0.0261

/ vCPU

/ HOUR

Billed Monthly, Always On

$280 per host/month (12 mo rate), or $350 monthly

Optimize the cost effectiveness of your game server with egress-free hosting of Private Fleets.

Persistent, available 24/7, exclusive to your studio.

Private Fleet (Bare Metal)

Reserved Capacity

$0.0261

/ vCPU

/ HOUR

Billed Monthly, Always On

$280 per host/month (12 mo rate), or $350 monthly

Optimize the cost effectiveness of your game server with egress-free hosting of Private Fleets.

Persistent, available 24/7, exclusive to your studio.

Your bill varies per rate and usage; which can vary per game type, player count, & more.

Your bill varies per rate and usage; which can vary per game type, player count, & more.

Model your usage with our estimate calculator ->

Model your usage with our estimate calculator ->

Edgegap's features & price: detailed comparison between Edge Cloud & Private Fleets

Edgegap's features & price: detailed comparison between Edge Cloud & Private Fleets

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.