Game Server Hosting

Edgegap

Host your PurrNet dedicated servers on Edgegap

This guide covers hosting your PurrNet dedicated servers on Edgegap, a game server orchestration platform. Edgegap runs your server as a container, so there is nothing PurrNet-specific to install. If your server builds to Linux and runs in Docker, it runs on Edgegap.

You will need an Edgegap account and your token at hand to follow this guide.

PurrNet has no built-in Edgegap integration. Everything on the Unity side is done with Edgegap's own Unity plugin, and your transport is configured like it would be for any other dedicated server.

What you'll need

  • Docker (Desktop or CLI), to containerize your server build. Make sure it's running when you want to upload a new build.
  • Unity Linux Dedicated Server Build Support, added through Unity Hub (Installs → Add Modules).
  • Edgegap's Unity plugin. Follow their getting started guide to install it.

Setting up PurrNet

Make sure your NetworkManager starts as a server in the build. The simplest way is to set the network manager's Start Server Flags to start in server builds, so it begins listening as soon as the container boots.

Then pick a fixed server port on your transport, for example 5000 on the UDP transport. This is the internal port of your container, and it has to match the port you declare in your Edgegap app version, with the matching protocol (UDP for the UDP transport, WS or WSS for the Web Transport).

Edgegap maps a random external port to your internal port for every deployment. Your server keeps listening on the internal port, and your clients connect to the external one.

If you would rather not hardcode the port, Edgegap injects the deployment's details as environment variables (ARBITRIUM_PORTS_MAPPING holds the port mapping), which you can read on the server and apply to your transport before starting it.

Deploying the server

There are a few steps required to go from nothing to a deployed server:

  1. Unity Linux build
  2. Containerize the build files
    1. This is why you need Docker installed. If you are not familiar with Docker, you can think of this step almost like zipping your project.
  3. Upload the container to Edgegap
  4. Deploy your application!

Edgegap's documentation has the detailed step by step, but here is a quick run through.

Speed running first server

First, open Edgegap's editor window.

Then fill in your token:

Once your token is set up and validated we can proceed to step 2 (building your server). All you have to do is press the Build Server button. This is just like a normal Unity build, so make sure you have your scene list properly set up. The build target will be a Linux dedicated server, which is why you had to install the extra modules.

With the build done we need to containerize it. This is where Docker comes into play, it packages your build in a way that Edgegap can work with. Just press Containerize with Docker.

We will skip step 4, you can use it to run the container you just created to test the server locally (even if your operating system isn't Linux).

In step 5 you need to choose your target application, a server image name (this can be whatever you want) and finally press the Upload image and Create app version button.

Once it finishes you can either Deploy to Cloud from the website dashboard or from step 6.

Every container you upload will have a version, by default it's the date that it was built at, which you can use to select the latest.

Connecting your clients

Once you have a deployment running you can connect from your editor or a client build.
On the website's dashboard you can find the information required to connect:

Use the Host as your transport's address and the External port as its port. For a quick test you can type them straight into the transport's inspector. In a real game you would get them from your matchmaker or backend and set them before starting the client:

udpTransport.address = host;
udpTransport.serverPort = externalPort;
networkManager.StartClient();

Easy as that!

Now you know how to get a server up and running and connect to it!
You can expand on this by using their matchmaking service to automatically create matches for your users.