Get started with session Dedicated Server customization
Overview
This article walks you through the workflow of creating and using a simple custom session to request a dedicated game server from an external provider. For this purpose, the Extend Override app template for the session function is used.
Prerequisites
- Go
- C#
- Python
Windows 11 WSL2 or Linux Ubuntu 22.04 or macOS 14+ with the following tools installed:
a. Bash
On Windows WSL2 or Linux Ubuntu:
bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
...On macOS:
bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)
...
b. Make
On Windows WSL2 or Linux Ubuntu:
To install from the Ubuntu repository, run
sudo apt update && sudo apt install make
.make --version
GNU Make 4.3
...On macOS:
make --version
GNU Make 3.81
...
c. Docker (Docker Desktop 4.30+/Docker Engine v23.0+)
On Linux Ubuntu:
- To install from the Ubuntu repository, run
sudo apt update && sudo apt install docker.io docker-buildx docker-compose-v2
. - Add your user to the
docker
group:sudo usermod -aG docker $USER
. - Log out and log back in to allow the changes to take effect.
- To install from the Ubuntu repository, run
On Windows or macOS:
Follow Docker's documentation on installing the Docker Desktop on Windows or macOS.
docker version
...
Server: Docker Desktop
Engine:
Version: 24.0.5
...
d. Go v1.22
Follow Go's installation guide to install Go.
go version
go version go1.22.0 ...
e. Curl
On Windows WSL2 or Linux Ubuntu:
To install from the Ubuntu repository, run
sudo apt update && sudo apt install curl
.curl --version
curl 7.81.0 (x86_64-pc-linux-gnu)
...On macOS:
curl --version
curl 8.4.0 (x86_64-apple-darwin23.0) ...
...
f. Jq
On Windows WSL2 or Linux Ubuntu:
To install from the Ubuntu repository, run
sudo apt update && sudo apt install jq
.jq --version
jq-1.6
...On macOS:
To install using Homebrew, run
brew install jq
.jq --version
jq-1.7.1
g. Postman
- Use the available binary from Postman.
h. ngrok
- Follow ngrok's installation guide.
- Use the available binary from extend-helper-cli.
Windows 11 WSL2 or Linux Ubuntu 22.04 or macOS 14+ with the following tools installed:
a. Bash
On Windows WSL2 or Linux Ubuntu:
bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
...On macOS:
bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)
...
b. Make
On Windows WSL2 or Linux Ubuntu:
To install from the Ubuntu repository, run
sudo apt update && sudo apt install make
.make --version
GNU Make 4.3
...On macOS:
make --version
GNU Make 3.81
...
c. Docker (Docker Desktop 4.30+/Docker Engine v23.0+)
On Linux Ubuntu:
- To install from the Ubuntu repository, run
sudo apt update && sudo apt install docker.io docker-buildx docker-compose-v2
. - Add your user to the
docker
group:sudo usermod -aG docker $USER
. - Log out and log back in to allow the changes to take effect.
- To install from the Ubuntu repository, run
On Windows or macOS:
Follow Docker's documentation on installing the Docker Desktop on Windows or macOS.
docker version
...
Server: Docker Desktop
Engine:
Version: 24.0.5
...
d. .NET 6 SDK
On Linux Ubuntu:
To install from the Ubuntu repository, run
sudo apt-get update && sudo apt-get install -y dotnet-sdk-6.0
.On Windows or macOS:
Follow Microsoft's documentation for installing .NET on Windows or on macOS.
dotnet --version
6.0.128
e. Postman
- Use the available binary from Postman.
f. ngrok
- Follow ngrok's installation guide.
- Use the available binary from extend-helper-cli.
Windows 11 WSL2 or Linux Ubuntu 22.04 or macOS 14+ with the following tools installed:
a. Bash
On Windows WSL2 or Linux Ubuntu:
bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
...On macOS:
bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)
...
b. Make
On Windows WSL2 or Linux Ubuntu:
To install from the Ubuntu repository, run
sudo apt update && sudo apt install make
.make --version
GNU Make 4.3
...On macOS:
make --version
GNU Make 3.81
...
c. Docker (Docker Desktop 4.30+/Docker Engine v23.0+)
On Linux Ubuntu:
- To install from the Ubuntu repository, run
sudo apt update && sudo apt install docker.io docker-buildx docker-compose-v2
. - Add your user to the
docker
group:sudo usermod -aG docker $USER
. - Log out and log back in to allow the changes to take effect.
- To install from the Ubuntu repository, run
On Windows or macOS:
Follow Docker's documentation on installing the Docker Desktop on Windows or macOS.
docker version
...
Server: Docker Desktop
Engine:
Version: 24.0.5
...
d. Python 3.9
To install from Ubuntu repository, run:
sudo apt update && sudo apt install python3 python3-venv
python3 --version
Python 3.9.x
e. Postman
- Use the available binary from Postman.
f. ngrok
- Follow ngrok's installation guide.
- Use the available binary from extend-helper-cli.
- Access to the AGS Admin Portal environment.
- Base URL:
<your environment's domain URL>
- Example for AGS Shared Cloud customer:
https://spaceshooter.prod.gamingservices.accelbyte.io
- Example for AGS Private Cloud customer:
https://dev.customer.accelbyte.io
- Example for AGS Shared Cloud customer:
- Create a game namespace if you don't have one yet. Take note of the namespace ID.
- Create an OAuth Client with
confidential
client type. Keep theClient ID
andClient Secret
.
- Base URL:
Clone the app template
- Go
- C#
- Python
git clone https://github.com/AccelByte/session-dsm-grpc-plugin-go.git
git clone https://github.com/AccelByte/session-dsm-grpc-plugin-csharp.git
git clone https://github.com/AccelByte/session-dsm-grpc-plugin-python.git
Set up, run, and test an Extend app
This section covers how to set up, build, run, and then test an Extend app.
Set up the Extend app
To run the sample custom functions of an Extend app, follow these steps:
Create a docker compose
.env
file by copying the content of the.env.template
file.注記The host OS environment variables have higher precedence compared to the
.env
file variables. If the variables in the.env
file do not seem to take effect properly, check if there are host OS environment variables with the same name. For more details, refer to Docker's documentation about the docker compose environment variables precedence.Fill in the required environment variables in
.env
file as shown below:- Go
- C#
- Python
AB_BASE_URL=https://prod.gamingservices.accelbyte.io # Base URL of AGS prod environment
AB_CLIENT_ID='xxxxxxxxxx' # Client ID from the Prerequisites section
AB_CLIENT_SECRET='xxxxxxxxxx' # Client Secret from the Prerequisites section
PLUGIN_GRPC_SERVER_AUTH_ENABLED=false # Enable or disable access token and permission verification
DS_PROVIDER='DEMO' # Select DS implementation: DEMO or GCP
// GCP Config
GCP_SERVICE_ACCOUNT_FILE='./account.json' # GCP service account file in JSON format
GCP_PROJECT_ID=xxxxx-xxxx # GCP Project ID
GCP_NETWORK=public # GCP Network type
GCP_MACHINE_TYPE=e2-micro # GCP instance type
GCP_REPOSITORY=asia-southeast1-docker.pkg.dev/xxxx/gcpvm # GCP Repository
GCP_RETRY=3 # GCP Retry to get instance
GCP_WAIT_GET_IP=1 # GCP wait time to get the instance IP in seconds
GCP_IMAGE_OPEN_PORT=8080 # Dedicated server open portAB_BASE_URL=https://prod.gamingservices.accelbyte.io # Base URL of AGS prod environment
AB_CLIENT_ID='xxxxxxxxxx' # Client ID from the Prerequisites section
AB_CLIENT_SECRET='xxxxxxxxxx' # Client Secret from the Prerequisites section
PLUGIN_GRPC_SERVER_AUTH_ENABLED=false # Enable or disable access token and permission verification
DS_PROVIDER='DEMO' # Select DS implementation: DEMO or GCP
// GCP Config
GCP_SERVICE_ACCOUNT_FILE='./account.json' # GCP service account file in JSON format
GCP_PROJECT_ID=xxxxx-xxxx # GCP Project ID
GCP_NETWORK=public # GCP Network type
GCP_MACHINE_TYPE=e2-micro # GCP instance type
GCP_REPOSITORY=asia-southeast1-docker.pkg.dev/xxxx/gcpvm # GCP Repository
GCP_RETRY=3 # GCP Retry to get instance
GCP_WAIT_GET_IP=1 # GCP wait time to get the instance IP in seconds
GCP_IMAGE_OPEN_PORT=8080 # Dedicated server open portAB_BASE_URL=https://prod.gamingservices.accelbyte.io # Base URL of AGS prod environment
AB_CLIENT_ID='xxxxxxxxxx' # Client ID from the Prerequisites section
AB_CLIENT_SECRET='xxxxxxxxxx' # Client Secret from the Prerequisites section
PLUGIN_GRPC_SERVER_AUTH_ENABLED=false # Enable or disable access token and permission verification
DS_PROVIDER='DEMO' # Select DS implementation: DEMO or GCP
// GCP Config
GCP_SERVICE_ACCOUNT_FILE='./account.json' # GCP service account file in JSON format
GCP_PROJECT_ID=xxxxx-xxxx # GCP Project ID
GCP_NETWORK=public # GCP Network type
GCP_MACHINE_TYPE=e2-micro # GCP instance type
GCP_REPOSITORY=asia-southeast1-docker.pkg.dev/xxxx/gcpvm # GCP Repository
GCP_RETRY=3 # GCP Retry to get instance
GCP_WAIT_GET_IP=1 # GCP wait time to get the instance IP in seconds
GCP_IMAGE_OPEN_PORT=8080 # Dedicated server open port注記In this app template,
PLUGIN_GRPC_SERVER_AUTH_ENABLED
istrue
by default. If it is set tofalse
, thegRPC server
can be invoked without theAccelByte Gaming Services
access token. This option is provided for development purposes only. It is recommended to enablegRPC server
access token validation in the production environment.
Build the Extend app
- Go
- C#
- Python
To build this app template, run the following command:
make proto // To generate session-dsm_grpc.pb.go
docker build -f Dockerfilegcpvm . // This is for GCP virtual machine
To build this app template, use the following command.
make build
To build this app template, use the following command.
make build
Run the Extend app
- Go
- C#
- Python
To (build and) run this app template in a container, run the following command:
docker-compose -f docker-compose-gcpvm.yaml up --build // This is for GCP server
To (build and) run this app template in a container, run the following command:
docker compose up --build
To (build and) run this app template in a container, run the following command:
docker compose up --build
Test the Extend app
You can test the Extend app in a local development environment or with AGS.
Test in a local development environment
Before testing, make sure PLUGIN_GRPC_SERVER_AUTH_ENABLED
is set to false
. Otherwise, the gRPC request will be rejected by the gRPC server
.
The custom functions in this app template can be tested locally using Postman. To test the Extend app using Postman, follow these steps:
Run the
dependency services
by following theREADME.md
in the grpc-plugin-dependencies repository.warningMake sure to start dependency services with mTLS disabled for now: It is currently not supported by
AccelByte Gaming Services
, but it will be enabled later on to improve security. If it is enabled, the gRPC client calls without mTLS will be rejected.Use the following command to run this
gRPC server
app template:
- Go
- C#
- Python
docker-compose -f docker-compose-gcpvm.yaml up --build // This is for GCP server
docker compose up --build
docker compose up --build
In Postman, create a new
gRPC request
and enterlocalhost:10000
as the server URL. This configuration essentially accesses thegRPC server
through anEnvoy
proxy independency services
. For more information, refer to Postman's documentation on creating gRPC requests.Still in Postman, continue by selecting
CreateGameSession
gRPC call method and clickInvoke
button. This starts streaming connection into the gRPC server app template.Continue sending parameters to specify the number of players in a match by copying and sending the sample JSON data below.
{
"client_version": "test",
"deployment": "test-deployment",
"game_mode": "test-game",
"maximum_player": "10",
"namespace": "testing",
"requested_region": [
"us-west-1",
"us-west-2"
],
"session_data": "testing",
"session_id": "uuidv4"
}
Test with AGS
To test the app template, which runs locally with AGS, the gRPC server
needs to be connected to the internet. To do this without requiring public IP, you can use ngrok.
- Run this
gRPC server
app template by using the following command:
- Go
- C#
- Python
docker compose up --build
docker compose up --build
Sign in to ngrok and get your
authtoken
from the ngrok dashboard.In this app template root directory, expose the
gRPC server
port in the local development environment to the internet by running the following command:make ngrok NGROK_AUTHTOKEN=xxxxxxxxxxx
Take note of the
ngrok
forwarding URL, e.g.,http://0.tcp.ap.ngrok.io:xxxxx
.In the Admin Portal, go to the correct namespace for the configuration and do the following:
- On the sidebar menu, go to Multiplayer > Matchmaking > Session Configuration.
- Click on the Add Session Template button.
- Select the Server configuration to be a DS - Custom. Then, select the Custom URL option and provide the
ngrok
forwarding URL from step 3.
Create an OAuth Client with
confidential
client type and containing the following permissions:- For AGS Private Cloud customers:
NAMESPACE:{namespace}:MMV2GRPCSERVICE [READ]
important- Keep a copy of the
Client ID
andClient Secret
. - The Oauth Client created in this step is different from the one mentioned in the Prerequisites section. It is required by the CLI demo app for the next step.
- For AGS Private Cloud customers:
Create a game session manually or via the matchmaking process and the session will request a DS from the GCP platform instead.
Deploy in AGS
Deploying an Extend app in AGS involves the following steps in the Admin Portal:
- Create the Extend app.
- Upload the Extend app.
- Configure the Extend app.
- Deploy the Extend app.
- Set AGS to use the Extend app.
Create the Extend app
- In the AGS Admin Portal, go to the namespace where you wish to create your Extend Override app.
- On the sidebar menu, under ADD-ONS, go to Extend > Override.
- On the Overridable Feature page, click on the + Create New button.
- On the Create App form, provide a name and description (optional) for your Extend app.
- Click Create. Your new Extend app is added to the Overridable Feature app list.
Upload the Extend app
Set up an OAuth Client for extend-helper-cli.Create an OAuth Client with
confidential
client type and containing the following permission:- For AGS Private Cloud customers:
ADMIN:NAMESPACE:{namespace}:EXTEND:REPOCREDENTIALS
[READ]ADMIN:NAMESPACE:{namespace}:EXTEND:APP
[READ]
- For AGS Shared Cloud customers:
- Extend > Extend app image repository access (Read)
- Extend > App (Read)
Keep a copy of the
Client ID
andClient Secret
.- For AGS Private Cloud customers:
Copy the extend-helper-cli command to perform docker login on the Extend app details page under Repository Authentication Command.
Export the required environment variables and perform docker login using extend-helper-cli. Run this command:
- Linux
- Windows (WSL2)
- macOS
# Your AGS environment base URL, e.g., https://spaceshooter.prod.gamingservices.accelbyte.io, https://dev.accelbyte.io, etc.
export AB_BASE_URL='https://xxxxxxxxxx'
# Client ID of OAuth Client for extend-helper-cli (from step 1)
export AB_CLIENT_ID='xxxxxxxxxx'
# Client Secret of OAuth Client for extend-helper-cli (from step 1)
export AB_CLIENT_SECRET='xxxxxxxxxx'
# The command to perform docker login (from step 2)
./extend-helper-cli-linux_amd64 dockerlogin --namespace <game namespace> --app <app name> --login# Your AGS environment base URL, e.g., https://spaceshooter.prod.gamingservices.accelbyte.io, https://dev.accelbyte.io, etc.
export AB_BASE_URL='https://xxxxxxxxxx'
# Client ID of OAuth Client for extend-helper-cli (from step 1)
export AB_CLIENT_ID='xxxxxxxxxx'
# Client Secret of OAuth Client for extend-helper-cli (from step 1)
export AB_CLIENT_SECRET='xxxxxxxxxx'
# The command to perform docker login (from step 2)
./extend-helper-cli-linux_amd64 dockerlogin --namespace <game namespace> --app <app name> --login# Your AGS environment base URL, e.g., https://spaceshooter.prod.gamingservices.accelbyte.io, https://dev.accelbyte.io, etc.
export AB_BASE_URL='https://xxxxxxxxxx'
# Client ID of OAuth Client for extend-helper-cli (from step 1)
export AB_CLIENT_ID='xxxxxxxxxx'
# Client Secret of OAuth Client for extend-helper-cli (from step 1)
export AB_CLIENT_SECRET='xxxxxxxxxx'
# The command to perform docker login (from step 2)
./extend-helper-cli-darwin_amd64 dockerlogin --namespace <game namespace> --app <app name> --loginimportantWe recommend running the above commands in a separate terminal and in a different working directory than the Extend app project. This is to reduce the chances of the extend-helper-cli picking up the environment variables for the Extend app project instead.
The output of a successful login looks similar to the following:
INFO[0000] signing in to https://dev.accelbyte.io
INFO[0001] getting docker credentials...
WARNING! Your password will be stored unencrypted in /home/xyz-abc/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login SucceededimportantIf you get the following error, refer to Troubleshooting: Docker login fails for troubleshooting steps .
Error saving credentials: error storing credentials - err: exit status 1, out: `error storing credentials - err: exit status 1, out: `The stub received bad data.`
Upload the Extend app container image to AGS using
extend-helper-cli image-upload
command. You can specify your extend app project by using-w
parameter. For image tag, you can put v0.0.1. For example:- Linux
- Windows (WSL2)
- macOS
./extend-helper-cli-linux_amd64 image-upload -n <game namespace> -a <app name> -w <extend app source dir> -t <image tag>
./extend-helper-cli-linux_amd64 image-upload -n <game namespace> -a <app name> -w <extend app source dir> -t <image tag>
./extend-helper-cli-darwin_amd64 image-upload -n <game namespace> -a <app name> -w <extend app source dir> -t <image tag>
備考You can use the
--login
parameter to log in and upload the image simultaneously using a single command. Refer to the extend-helper-cli README text for more details.If your images are successfully uploaded, you will see an image with version v0.0.1 on the Image Version History page.
Configure the Extend app
Before deploying the Extend app that you uploaded, you must configure the environment variables required by the Extend app. In the app's details page, set the following environment variables with the same values that you used to run and test the Extend app locally.
AB_CLIENT_ID
AB_CLIENT_SECRET
If your Extend Override app is based on app templates before release v2024.02.13, make sure to set PLUGIN_GRPC_SERVER_AUTH_ENABLED
environment variable to true
. Otherwise, the access token validation in the Extend app is disabled and your Extend app may be accessed without a valid access token.
Since release v2024.02.13**, PLUGIN_GRPC_SERVER_AUTH_ENABLED
in Extend Override app templates is set to true
by default. The access token validation can only be disabled when PLUGIN_GRPC_SERVER_AUTH_ENABLED
is explicitly set to false
. To align with this, all new Extend apps created through the Admin Portal will not have PLUGIN_GRPC_SERVER_AUTH_ENABLED
environment variable set by default. Previously, PLUGIN_GRPC_SERVER_AUTH_ENABLED=false
is added on all new Extend apps created through the Admin Portal.
Deploy the Extend app
To deploy the Extend app, click Deploy Latest Image. Wait until the app status updates to RUNNING, which indicates that your Extend app is successfully deployed.
Set AGS to use the Extend app
In the AGS Admin Portal, go to the namespace you wish to use to create your custom function. On the Admin Portal sidebar, click on Multiplayer > Matchmaking > Session Configuration. On the Session Configurations page, click on the Add Session Template button. When you create your session template, make sure to choose the DS - Custom option for server selection. From the list, choose the AccelByte Hosted option and select the name of the Extend App you created. Then, click Save to create the new session template.
Next step
Proceed to modify this app template and create your own Extend Override app for session function. See Introduction to session customization for more details.