- Newest
- Most votes
- Most comments
Hello,
I am using the c++ sdk and not the c# one, and after digging further, it uses the environment variables before the server parameters, so it should work if the env variables are set.
So I have run a micro game server that just dump the environment variables, and the env variables bellow do not exist for the game server process spawned on a gamelift managed fleet, so I suppose this is where is the issue. I suppose the older versions of the SDK didn't uses them as game server built with the sdk 06_03_2021 still works, and I didn't found references to those variables in the sdk 06_03_2021 code.
Is there something additional to do on the fleet configuration, so gamelift add those environment variables when launching the game server executable?
The missing environment variables:
- GAMELIFT_SDK_WEBSOCKET_URL
- GAMELIFT_SDK_AUTH_TOKEN
- GAMELIFT_SDK_PROCESS_ID
- GAMELIFT_SDK_HOST_ID
- GAMELIFT_SDK_FLEET_ID
Have a nice day, Victor
Hi,
The ServerParameters
argument is not required in the managed EC2 fleets, but there is currently no way to pass in a null ServerParameters
due to how to SDK is implemented -- e.g. in C#, ServerParameters
is implemented as a struct
and therefore is not nullable.
GameLift has plans to implement a parameterless initSDK()
method, in the mean time, you can work around this by constructing ServerParameters with null
values, e.g.
ServerParameters serverParameters = new ServerParameters(null, null, null, null, null);
if (InitSdk(serverParameters))
{
...
}
A slightly more robust way to implement this is by passing in ServerParameters values using CLI to the server process executable, for example:
public static void Main(string[] args)
{
Options options = new Options();
if (CommandLine.Parser.Default.ParseArguments(args, options))
{
ServerParameters serverParameters = new ServerParameters(option.WebSocketUrl, option.ProcessId, option.ComputeId, option.FleetId, option.AuthToken);
if (InitSdk(serverParameters))
{
...
}
}
}
public class Options
{
[Option('w', "websocketUrl", DefaultValue = null, HelpText = "WebSocket URL from RegisterCompute for communicating with GameLift.")]
public string WebSocketUrl { get; set; }
[Option('x', "processId", DefaultValue = null, HelpText = "Host process ID for this host process.")]
public string ProcessId { get; set; }
[Option('i', "computeId", DefaultValue = null, HelpText = "Compute ID from RegisterCompute associated with this host process.")]
public string ComputeId { get; set; }
[Option('f', "fleetId", DefaultValue = null, HelpText = "Fleet from CreateFleet associated with this compute.")]
public string FleetId { get; set; }
[Option('n', "authToken", DefaultValue = null, HelpText = "Authentication token from GetComputeAuthToken for this process.")]
public string AuthToken { get; set; }
}
Then, when testing your server process locally with GameLift anywhere (see doc), you may execute your server process as such: ./MyServer --websocketUrl <results from RegisterCompute> --processId my-process-id-123 --computeId <input to RegisterCompute> --fleetId <results from CreateFleet> --authToken <results from GetComputeAuthToken>
When running the same executable in the managed EC2 instance, you can set the RuntimeConfiguration as /local/game/MyServer
without any parameters, as they will default to null
.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 4 years ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated a year ago
Hi Victor, when creating your Build, did you by any chance set your build's ServerSdkVersion? Those environment variables would not be set unless the ServerSdkVersion is
5.0.0
or above. Sorry if the doc is unclear, I can relay this to the doc team to see if improvements can be made.CreateBuild Doc: https://docs.aws.amazon.com/gamelift/latest/apireference/API_CreateBuild.html#gamelift-CreateBuild-request-ServerSdkVersion
Hi James, it was totally that, we missed this argument in our automated build deployment system, so it was defaulting to 4.0.2. It is working now. Thanks a lot for the help!