Discover how Edgegap works

Discover how Edgegap works

/

Photon Fusion 2

/

Photon Fusion 2

Deploy to Edgegap

Published

Published

Published

Photon Fusion 2: How to integrate and host dedicated servers for your multiplayer game

Photon Fusion 2: How to integrate and host dedicated servers for your multiplayer game

This guide shows you how to host a game built with Photon Fusion 2 on Edgegap's dedicated game servers. The server runs headless in GameMode.Server, so no player hosts the match.

Once your game server is containerized, Edgegap deploys it on demand from a simple API call, to the best available location for its players among 615+ Edge Cloud locations (learn more), billed exclusively on usage: no entire server to rent, provision or keep running between matches. For persistent servers of reserved capacity, Edgegap offers Private Fleets.

Your Photon setup doesn't change: players still find and join matches through Photon Cloud, with your own App ID. Edgegap only runs the server.

Photon's Fusion 2 documentation lists Edgegap as a game session hosting provider (Photon's dedicated server page). A Photon Public Cloud subscription is enough to run a game in Server Mode with a dedicated game server.

This guide covers:

  1. Preparing Unity, Photon, your Edgegap account and a containerization tool

  2. Connecting your coding agent to Edgegap (optional)

  3. Getting your Fusion game ready for dedicated servers

  4. Building and containerizing your game server

  5. Deploying a test server and connecting to it

  6. How players find the server

  7. Testing with two players

You can do it two ways, and mix them:

  • With a coding agent. Connect Claude Code, Cursor or another agent to the Edgegap MCP server and its agent skills. The agent edits your project, builds and containerizes the server, and deploys it. You handle the clicks in Unity, the Photon and Edgegap dashboards, and playtest.

  • By hand. Every step below also works without an agent.

For building and containerizing the server, Edgegap's automated game server build tool plugin for Unity is optional. It builds your server, containerizes it and deploys it to the cloud from buttons in the Unity Editor, the quickest way to see your server online for the first time (step 4, Option A).

Here, we use Edgegap's version of Photon's Asteroids Simple (Host) sample, already set up to run as a dedicated server. Any Fusion 2 project works the same way. For bigger games, see the BR200 and Simple FPS samples in Next Steps.

Sample: Unity 6.0 LTS (the project is saved with 6000.0.41f1), Fusion 2.0.6, server on Linux, clients in the Unity Editor. Photon's sample code stays under Photon's licence terms.

Photon Fusion 2

x

Edgegap

Fully Endorsed by

Fully Endorsed by

Photon's Fusion 2

Photon's Fusion 2

Photon's Fusion 2 documentation lists Edgegap as a game session hosting provider for dedicated servers, with this Asteroids sample.

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.

Step-by-Step Guide

Detailed Integration Steps

1. Before you start

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

  • A Photon account and your own Fusion 2 App ID. In the Photon dashboard, create an app (Multiplayer Game, Fusion SDK, Fusion 2) and copy its App ID. Every developer needs their own.

  • Unity Engine with the Linux build modules installed. Edgegap recommends an LTS version.

  • Add these modules from Unity Hub: Linux Build Support (Mono), Linux Build Support (IL2CPP) and Linux Dedicated Server Build Support. Restart Unity after adding them.

  • Asteroids: use Unity 6.0 LTS, the version the sample is saved with (6000.0.41f1). When you add the project in Unity Hub, install that version or a later 6000.0 patch. Newer Unity versions haven't been tested with this sample. Your own Fusion project can use any LTS version: Edgegap's Fusion skill was tested with Unity 6.3 LTS.

  • A containerization tool, running. We recommend Docker Desktop, installed and running while you build.

  • Other container tools work with Edgegap too, but this guide only covers 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 the Edgegap plugin. macOS usually has one already (Xcode Command Line Tools); on Windows, install 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 create apps and versions, deploy servers and read logs on your account. The agent skills give it the tested Fusion workflow (the edgegap-fusion skill), the Dockerfile and the known pitfalls.

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/edgegap-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/edgegap-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. An error about the token usually means the header reads token token ....

3. Get your Fusion server ready for dedicated hosting

On Edgegap, no player hosts the match. A headless Fusion server owns the game: it starts on its own in GameMode.Server, registers a session with Photon Cloud, and clients join that session by name. Three things must match on the server and the clients, or clients get "Game Does Not Exist": the App ID, the App Version and the Photon region.

Asteroids: Edgegap's version is already dedicated-server ready. Open it in Unity Hub (Add → Add project from disk), then:

  1. Open Tools → Fusion → Realtime Settings and paste your own App ID in App Id Fusion. Save the project (File → Save Project) so the change sticks.

  2. Check Tools → Fusion → Network Project Config: Peer Mode is Single. It already is in the sample.

  3. Check File → Build Profiles (Build Settings): both scenes in Assets/Asteroids-Host-Simple/Scenes are enabled, AsteroidsSimple-Menu first.

What the sample adds is one script, Assets/EdgegapHelpers/EdgegapServerManager.cs, on a GameObject in the Menu scene. In a server build it reads Edgegap's environment variables, names the session after the deployment ({request_id}.pr.edgegap.net), binds 0.0.0.0:7777, gives Fusion the deployment's public IP and external port, and starts the game scene. The menu's Start Edgegap button joins that session as a client.

Your own Fusion game, with your agent. The fork is a working reference: your coding agent starts from files that already ran on Edgegap, so it builds on a tested setup instead of guessing.

"Load the edgegap-fusion skill and make this Photon Fusion 2 project dedicated-server ready, using https://github.com/edgegap/netcode-game-sample-photon-fusion2-asteroid as the reference: the server build starts a NetworkRunner in GameMode.Server in batch mode, binds 0.0.0.0 on port 7777, names the session after the Edgegap deployment, and uses a Photon region the clients will use. Clients join that session by name. When the match ends, the server shuts the runner down and exits. Then check it still works locally with one server and two clients."

By hand, in your project:

  • Start the server in batch mode with GameMode.Server, and Address = NetAddress.Any(7777). Don't bind the deployment's public IP: the container doesn't own it, and the server fails to start.

  • Name the session after the deployment: {ARBITRIUM_REQUEST_ID}.pr.edgegap.net.

  • Keep Peer Mode on Single in the Network Project Config.

  • Build the server with the Dedicated Server platform (the Server subtarget), so it runs headless.

  • When the match ends, shut the runner down and quit the application, so the deployment stops and stops billing.

  • Never print the environment at startup: it holds the deployment's delete token.

4. Build and containerize your server

Edgegap runs your Linux server build inside a container. Use either option, or both.

Option A (optional): Edgegap's automated game server build tool plugin for Unity. The quickest way to a first cloud deploy, all from buttons. It uses Docker to containerize your server. The Asteroids sample already includes it.

  1. For your own project: select Window → Package Manager, select +, then Install package from git URL, and paste https://github.com/edgegap/edgegap-unity-plugin.git.

  2. Open Tools → Edgegap Server Hosting. Under 1. Connect your Edgegap Account, select Sign in with Edgegap (or Get token), paste your token, and select Validate token.

  3. Under 2. Build Your Game Server, select Build server.

  4. With Docker running, under 3. Containerize Your Server, select Containerize with Docker. Optionally, under 4. Test Your Server Locally, select Deploy local container.

  5. Under 5. Upload to Edgegap, select Upload image and Create app version. In the browser, set the port to 7777, UDP, named gameport. Submit.

The plugin's default Dockerfile prints the container's environment at startup. That's fine for a test; before going live, use the edgegap-fusion skill's Dockerfile or your own.

Option B: ask your agent.

"Build the Linux dedicated server, containerize it for linux/amd64 with a Dockerfile that doesn't print the environment, push it to my Edgegap Container Registry with a new tag, then create the app and app version with port 7777 UDP named gameport."

The agent asks you to run docker login registry.edgegap.com yourself, with the username and token from the Container Registry page, so those credentials stay out of the chat. Make sure the app version has the registry credentials set: without them, deployments fail with "Unable to pull image from registry".

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

5. Deploy a test server and connect

Start one server by hand to prove the image, the port and your Photon settings work. Any of these works:

  • From the plugin: under 6. Deploy a Server on Edgegap, select Deploy to cloud.

  • From the dashboard: open your app version in the Edgegap dashboard, select Deploy, pick a location close to you, and deploy.

  • From your agent: "Deploy my latest Edgegap version near me, wait until it's ready, show me the logs, and give me the host URL."

When the deployment is Ready, copy its Host URL ({request_id}.pr.edgegap.net). With Fusion, that's the session name, not an address: Photon connects the client to the server.

Asteroids: open the AsteroidsSimple-Menu scene, press Play, paste the Host URL in Room Name, and select Start Edgegap. The server can take up to a minute after Ready to register its session.

If the client reports "Game Does Not Exist (32758)" while the server runs, the client is on another Photon region. Open Tools → Fusion → Realtime Settings and set Fixed Region to the Photon region closest to the deployment's location (for example us for Newark, cae for Montreal or Toronto, eu for Amsterdam; see Photon's region list). Save the project, then try again.

Stop the deployment when you're done: Stop last deployment in the plugin, the deployment's page in the dashboard, or ask your agent. The Asteroids server doesn't stop itself when a match ends, and the free tier runs one deployment at a time.

6. How players find the server

With Fusion, matchmaking stays on Photon Cloud. Each Edgegap deployment is one Fusion server and one session, named after the deployment. A client with the same App ID, App Version and region joins it by that name.

So your game needs something that starts a deployment for a match and hands its session name to the players:

  • For testing: copy the Host URL from the dashboard, as in step 5.

  • For a live game: your backend calls the Edgegap API to deploy near the players, then sends the session name to their clients. Edgegap's matchmaker can also do it: its match assignment returns the deployment's host name, which is the session name. Edgegap's matchmaker hasn't been tested with Fusion yet.

7. Test with two players

  1. Make sure no other test deployment is still running, then deploy one server (step 5).

  2. Run two clients. The Asteroids sample includes ParrelSync: select ParrelSync → Clones Manager, Create new clone, then Open in New Editor. Unity's Multiplayer Play Mode works too.

  3. In both, enter the same Host URL in Room Name and select Start Edgegap. Both ships appear in the same match.

  4. Play until one player is left. Both clients return to the menu.

  5. Stop the deployment (Stop last deployment in the plugin, or ask your agent). In your own game, make the server exit at the end of the match instead, so you only pay while players play.

On the free tier, deployments stop after 60 minutes and one deployment runs at a time.

Next Steps

Next Steps

Working with another Unity netcode? See Unity Engine.

Going live? Ask your agent to run the edgegap-launch skill's checklist: version rollouts, restart policy, maximum duration, cost control.

Stuck? Ask your agent to load edgegap-troubleshoot, or ask our team and other studios on the Edgegap Discord.

Frequently Asked Questions

Common questions about hosting a Photon Fusion 2 game on Edgegap's dedicated servers.

Does Photon Fusion 2 support dedicated servers?

Yes. Start a NetworkRunner in GameMode.Server from a headless Linux build. The server has state authority and no player. Photon's Fusion 2 documentation lists Edgegap as a game session hosting provider.

Do I need Photon Cloud with a dedicated server on Edgegap?

Yes. The server registers its session with Photon Cloud and clients join it by name, so both need the same App ID, App Version and region. Photon says a Public Cloud subscription is enough for Server Mode.

Which port does a Fusion server use on Edgegap?

The sample binds 7777 over UDP. Set the same port on your Edgegap app version, named gameport. Bind 0.0.0.0, never the deployment's public IP.

Why do clients get "Game Does Not Exist" when the server is running?

The client and the server use different Photon regions, App IDs or App Versions. Set the client's Fixed Region to the Photon region closest to the deployment, and check both use the same App ID and App Version.

How much does it cost to host a Fusion game server?

Testing on Edgegap is free, with no credit card. After that, Edge Cloud bills per vCPU per minute only while servers run, so a server that exits at the end of each match costs nothing between matches. Photon bills its own plan separately.

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.