Gamelift SDK 5.1.1 InitSDK error with On Demand instances

0

Hello,

I'm working on getting GameLift set up using the Server SDK 5.1.1, and I'm stuck on this error:

The server process did not call InitSDK() within the time expected. Check your game session log to see why InitSDK() was not called in time.

I tested with Anywhere locally to make sure everything works, and it does.

I tracked down how InitSDK() is called and updated to the main branch of the Unreal plugin (https://github.com/aws/amazon-gamelift-plugin-unreal) in order to be able to call InitSDK() without any params.

After seeing this other answer (https://repost.aws/questions/QU-jeCnExXRZWW3MGBZv8KMQ/gamelift-sdk-5-0-0-initsdk-for-on-demand-instances), I made sure my build had a specified "Server SDK version", and it does: 5.1.1

I tried to connect to the running instances using aws ssm start-session, but I just get:

An error occurred (TargetNotConnected) when calling the StartSession operation: i-xxxxxx is not connected.

I then tried adding more things to install.sh to get some debugging output. I added:

printenv
timeout 30s ./GameServer || true

That gives me some log output to work with, and I noticed two things:

printenv doesn't show any of the GameLift environment variables that I expect from reading the Server SDK code: GAMELIFT_SDK_WEBSOCKET_URL, GAMELIFT_SDK_AUTH_TOKEN, GAMELIFT_SDK_PROCESS_ID, GAMELIFT_SDK_HOST_ID, GAMELIFT_SDK_FLEET_ID

And my game server gives me (pruned a little):

GameServerLog: Initializing the GameLift Server
GameServerLog: Calling InitSDK() without parameters (assuming we're in an EC2 environment)
Connecting to GameLift WebSocket server. websocketUrl: , processId: , hostId: , fleetId: 
Connection to GameLift websocket server failed. Retrying connection if possible.
Connection to GameLift websocket server failed. Retrying connection if possible.
Connection to GameLift websocket server failed. Retrying connection if possible.
Connection to GameLift websocket server failed. Retrying connection if possible.
Connection to GameLift websocket server failed. Retrying connection if possible.
Connection to GameLift websocket server failed. See error message in InitSDK() outcome for details.

Notice the empty values it's using to try to connect to GameLift. This is in line with the missing environment variables (the Server SDK is trying to read everything from environment variables that don't exist). But I have no idea why the environment variables wouldn't be there.

Any help would be appreciated!

Thanks,

Allan

Allan
asked 6 months ago447 views
1 Answer
0
Accepted Answer

I figured it out: I was locking up the server by starting too many processes at the same time.

Once I set ConcurrentExecutions to 1, the fleet both activated successfully and I was able to remote in using aws ssm start-session. The GameLift environment variables aren't present in install.sh or for the remote user, so I imagine they must only be set for the shell that runs the game server process itself.

Sharing some troubleshooting notes for anyone else that runs into this error message (with a focus on Unreal, but it could be applicable to any game server).

Make sure your game server runs correctly locally:

  • Follow the directions to test locally with Anywhere.
  • Test by passing in the params as command line arguments. For unreal that looks something like: ./GameServer -authtoken=<authtoken> -hostid=DevLaptop -fleetid=fleet-xxxxxxx -websocketurl=wss://us-east-1.api.amazongamelift.com
  • When running with On Demand EC2 instances, the process needs to get those details via environment variables instead of command line arguments. Test that this works locally with a command something like this: GAMELIFT_SDK_WEBSOCKET_URL=wss://us-east-1.api.amazongamelift.com GAMELIFT_SDK_PROCESS_ID=1 GAMELIFT_SDK_AUTH_TOKEN=<authtoken> GAMELIFT_SDK_HOST_ID=DevLaptop GAMELIFT_SDK_FLEET_ID=fleet-xxxxxxx ./GameServer

Make sure you aren't overloading the server:

  • Set ConcurrentExecutions to 1.
  • Consider setting GameSessionActivationTimeoutSeconds to 300 or higher, just to test. The default seems to be 30 seconds, which is probably long enough for most game servers, but it's worth testing with a higher value just to make sure that's not what's happening.
  • Not necessary to test, but consider setting MaxConcurrentGameSessionActivations to something like 1. The default is to effectively start every process at the same time, which might be rough for something like Unreal.

Obviously dial in all these settings for what makes sense for your particular use case once you get it working initially, these are just helpful as a test baseline.

Best,

Allan

Allan
answered 6 months 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