Gamelift SDK 5.0.0 InitSDK for ON_DEMAND instances

0

Hello,

I have upgraded our game server to the latest sdk version (5.0.0). The new InitSDK takes a Aws::GameLift::Server::Model::ServerParameters parameter. For our deployed build I provide the struct with its default values, as in the documentation here: https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-server-sdk5-cpp-actions.html#integration-server-sdk5-cpp-initsdk it tell to ignore this parameter for GameLift managed EC2 instances. But the game server on the gamelift fleet failed the init of the sdk and the sdk returned this error: "Connection Failed / Connection to the GameLift Service WebSocket has failed". It is working perfectly with the old SDK version. I suspect it's an issue with the ServerParameter struct, but so far I didn't find anything. Any help about how to do the proper init with the sdk 5.0.0 would be greatly appreciated :)

Thanks, Victor

victor
asked a year ago555 views
2 Answers
0

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

victor
answered a year ago
0

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.

AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions