Test run local AMS server using AMS Simulator - Game server integration - (Unreal Engine module)
About
In this tutorial, you will learn how to test your dedicated server flow on AccelByte Multiplayer Servers (AMS) locally using AMS Simulator. AMS Simulator is the tool to verify how your dedicated server will react to state changes and unexpected events that originate from AMS. This way, you can make sure that your dedicated server will work properly with the flow without uploading the dedicated server first.
Run a local dedicated server
There are two ways of testing local dedicated servers in Unreal Engine: as a packaged dedicated server and run an uncooked server using the editor. Packaged dedicated servers uses less resources to run, but it takes longer to build, while using the editor uses more resources and takes less time to build. Choose one of those method based on your needs.
Package dedicated server
Compile your project and open it in the Unreal Engine editor. Then, package your game server for Windows.
For more information on packaging Unreal projects, read Packaging Projects.
This tutorial uses the Development build to enable logging for debugging purposes. Building as Shipping will disable logging.
Run uncooked dedicated server
Run this command using PowerShell to start the game server with the editor:
& "<your_ue5_dir>\UnrealEditor.exe" "<your_project_dir>\AccelByteWars.uproject" -server
Test run dedicated server locally
This section will test your packaged game server locally to check whether it is able to handle the state changes within the lifecycle of AMS.
Log in to the Admin Portal and go to your game namespace dashboard.
From the side bar menu, select Multiplayer Server Configuration > Download Resource. Locate and download AMS Simulator for Windows. The amssim.exe file should be downloaded.
Once the download is complete, run the AMS Simulator executable.
.\amssim.exe run
Here is the output of AMS Simulator. Notice that it provides an example ID format for your local dedicated server. This example is
ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
. Copy it, as you will need it in the next step.AMS simulator url ws://0.0.0.0:5555/watchdog
AMS simulator session id: 01hfaxxvfqhe9gkk2zesfx0b66.
AMS simulator session log path: session\01hfaxxvfqhe9gkk2zesfx0b66.log
Ready to accept local DS
Start the local DS with a valid DS ID that conforms to uuid standards
An example that can be copied and pasted is:
ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
==================================Command list=================================================
help show the command list again
info show AMS simulator info
ds
status show status of the ds
ready explicitly set ds into ready state.
claim claim the ds for a game session.
drain drain the ds
exit, quit exit ams simulator
=============================================================================================Run the game server executable or the uncooked server using Unreal Editor using the following commands below in Windows PowerShell. Notice that it uses the
ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
from the previous step as its local dedicated server ID.- Packaged
- Uncooked
C:/WindowsServer/AccelByteWarsServer.exe -server -log -nosteam -dsid=ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
& "<your_ue5_dir>\UnrealEditor.exe" "<your_project_dir>\AccelByteWars.uproject" -server -log -nosteam -dsid=ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
備考- -log will show game server's log.
- -nosteam is used to not run the Steam plugin on the game server side.
- -server is used to run the game as a server.
- -dsid is the dedicated server identification that will be used by the game server to initialize AMS configuration. You can use the example ID given by AMS Simulator. This example is
ds_018c1f42-5eb6-7ca3-9650-a732ed75ce6a
. Note that this launch parameter will be filled automatically on the AMS side when this dedicated server is launched in AMS.
Once your game server is running, check the server log to confirm the local server is connected to the AMS Simulator, similar to what's shown below under
LogAccelByteAMS
of the AMS logs:LogAccelByteAMS: Connecting to ws://localhost:5555/watchdog
LogAccelByteAMS: ConnectedYou can also confirm the successful connection from the AMS Simulator.
amssim> DS Connected
Check the dedicated server status using AMS Simulator by executing
ds status
. If the game server successfully registers, it will display the log below. Notice that theDS State
has changed toReady
.ds status
AMS Simulator will show the following log:
amssim> ds status
ID: xxxxx
Connected at: 2023-XX-XX 10:00:00
Last Heartbeat: 2023-XX-XX 10:00:00
DS State: ReadyYou can also verify if the game server can handle a drain state by executing
ds drain
. If you see the log lines below, your server successfully handles drain states. Notice that theDS State
has changed toDraining
.ds drain
AMS Simulator will show the following log:
amssim> ds status
no connected dedicated serverThe game server log should show the following and then shut down the server.
LogMultiplayerDSEssentials: Received AMS drain message; Shutting down the server now!
To quit AMS Simulator, execute the following command:
quit