Hello there, apologies for the delay getting back to you -
ProcessReady & ProcessParameters
Whenever your game server process launches and calls ProcessReady() in the GameLift Server SDK, you pass ProcessParameters into that call. Those ProcessParameters contain a parameter that tells GameLift what port that process is listening to for player connections. It also contains a parameter to tell GameLift where the server logs will be written to so GameLift can collect those for you later to help with debugging. More details are documented here:
- C++ SDK Guide
C# SDK Guide
Now, you might be asking yourself “well, how does my server process know what port it should use when contacting GameLift”? There are two options here depending on how your server process works.
Option 1: Your Server Process Auto-Detects the Port
Some game servers will automatically detect the port they should use by trying one, seeing if it’s in use and if so, trying another. In your example above, this would mean Server 1 starting with port 2101. No other servers are running, so Server 1 uses port 2101. Server 2 starts and tries port 2101. Unfortunately, port 2101 is in use, so Server 2 tries 2106 which is not in use, so Server 2 uses port 2106. Both Server 1 and Server 2 would communicate their selections to GameLift as part of the ProcessParameters in the ProcessReady call.
If your game server auto-detects the port as I describe, when you configure the multi-process setup in the fleet, you can simply tell GameLift to run 3 identical processes, for example:
- C:\game\server.exe, +some_args_here, 3
GameLift will start 3 server.exe processes, each of which will auto-detect their ports and update GameLift.
Option 2: Your Server Process Is Told the Port
If your game server needs to be told the port it should listen to when you launch it, you can solve this by telling GameLift to launch 3 server processes, each with slightly different command line arguments. You would do this as part of fleet creation when configuring the multi-process runtime configuration. For example:
- C:\game\server.exe, +port = 2101, 1
- C:\game\server.exe, +port = 2106, 1
- C:\game\server.exe, +port = 2111, 1
GameLift will start 3 server.exe processes but will pass slightly different command-line arguments to each, in this case, containing a different port. Your game server would then take that port setting and give it back to GameLift as part of the ProcessReady call later on. GameLift then knows which server process is expecting traffic on which port.
One thing to remember to do is to update your fleet with the inbound port settings that you have your server processes listening on. If you forget to do this, no outside player traffic will make its way to your servers, even though they are listening.
You can manage the open ports on your fleet in either the GameLift Management Console or by making API calls to UpdateFleetPortSettings:
Hopefully this gets you going! If you would like to learn a bit more about how to configure multi-process in GameLift here is a handy link: