You can use Unreal Editor’s Session Frontend profiler to monitor your server-worker instances’ performance in a cloud deployment. You can also use Session Frontend to test your game with Unreal console commands on a remote machine.
To debug your running worker instances in the cloud, do the following:
- Enable Messaging for the server-worker types you want to monitor.
Each server-worker listens to the same port on address
localhostdoes not work).
- Set up the connections from your local machine to the server-workers:
a. Connect to a local address.
b. Make a tunneling connection to the chosen worker.
Image: Connecting to server-workers from a local machine.
Each worker has its own Message Bus, which enables communication between parts of the application with message passing. You can use the TcpMessaging plugin to create a Message Bridge between your local machine and your workers in the cloud.
For more information, see the following:
To enable messaging (the Message Bus, Message Bridge and other components), you must add the flag
-messaging to the server-worker configuration. To do this:
- Open the file
<ProjectRoot>/spatial/workers/unreal/spatialos.UnrealWorker.worker.json. See <ProjectRoot> for more information.
- In the
linuxworker, add the flag
Next, specify the port you want the server-worker to listen on. There are two ways to do this:
- Option 1: With the Unreal Editor settings
- Option 2: In the
Option 1: With the Unreal Editor settings
- In the GDK toolbar, open the Start Deployment drop-down menu.
- Select Runtime Settings.
- In Plugins > TCP Messaging > Listen Endpoint, enter
0.0.0.0:<port number>, for example
- Rebuild your project in Visual Studio.
- Upload your project’s assemblies to your cloud deployment. The easiest way to do this is to select Build and Upload Assembly in the Cloud Deployment Configuration dialog.
Option 2: In the
- Add the following details to the
inifile. In this example, we use port number
- Upload the assemblies. You do not need to rebuild your project.
When you deploy your game, the Unreal Editor’s output console displays a log entry similar to the following:
You must set up your local Unreal Editor’s connection to each of your server-workers. In the Editor, you first specify the port for each server-worker you want to debug, and then you set up the tunneling.
For each server-worker you want to debug, do the following:
- In the Unreal Editor’s GDK toolbar, open the dropdown menu next to Start/Stop Deployment and select Runtime Settings.
- Open Plugins > TCP Messaging.
- Next to Connect to Endpoints, click + to add a new element.
- In the new element, enter
127.0.0.1:<port number>, where <port number> is the listening port of the server-worker. For example, you might enter
- Repeat steps 3-4 for each additional server-worker you want to debug. The following image shows a configuration for two server-workers:
- Open a command-line window and navigate to
<ProjectRoot>/spatial/. See <ProjectRoot> for more information.
- For each worker you want to debug, run the following command:
spatial project deployment worker port-forward -d=<deployment_name> -w=<<worker_id> -p=<port_number>
When you deploy your game, in the Editor’s log window you see a message that indicates that a bridge connection is established:
When you use Spatial TCP port forwarding, you avoid several problems associated with connecting to the cloud with a raw IP address. For example, you do not need to find the right IP address or deal with firewalls.
port-forward command allows you to connect to the cloud deployment directly through localhost.
When a bridge is established, worker sessions appear in the Session Frontend. In the Unreal Editor’s Window menu, select Developer Tools > Session Frontend.
Image: Session Frontend
Example remote commands:
log <log category name> <log verbosity>: Dynamically changes log verbosity for the given category. For example,
log LogGameState offdisables logging for the
obj gc: Triggers a garbage collection sweep.
memreport: Displays a detailed breakdown of memory usage per system.
To enable remote commands, you must add your Windows username to the list of authorized users.
You can find out your username in Visual Studio’s debug mode. To do that, check the value in
FApp::GetSessionOwner() to find out your username
FEngineService::FEngineService() add the following lines of code (where
<username> is your user name):
// always grant access to session owner AuthorizeUser(“<username>>”);
Add the code as follows:
When you deploy the game, you can use remote commands:
To run a remote command:
- In Unreal Editor, select Windows > Developer Tools > Session Frontend.
- In the command line box at the bottom of the Session Frontend window, enter your command.
- Click Send Command.
2021-01-14 Page updated with editorial review: fixed the Connect to Endpoints address
2020-09-23 Page added with editorial review.
Updated 8 months ago