Aws::GameLift::Server::GetGameSessionId(); EMPTY

Hello,

I am trying to get the game session id from inside the game server hosting that session.

In this function the “GetGameSessionIdOutcome.GetResult()” is empty every time, what could be the issue or a fix?

Thanks


void AMyGameMode::updateGameSession(FString newState, FString pass)
{
#if WITH_GAMELIFT
	TSharedPtr<FJsonObject> RequestObj = MakeShareable(new FJsonObject);
	RequestObj->SetStringField("newState", newState);
	RequestObj->SetStringField("pass", pass);
	
	auto GetGameSessionIdOutcome = Aws::GameLift::Server::GetGameSessionId();

	if (GetGameSessionIdOutcome.IsSuccess()) {
		RequestObj->SetStringField("gameSessionId", GetGameSessionIdOutcome.GetResult());
			
		FString RequestBody;
		TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&RequestBody);
		if (FJsonSerializer::Serialize(RequestObj.ToSharedRef(), Writer)) {
			TSharedRef<IHttpRequest> UpdateRequest= HttpModule->CreateRequest();
			
			UpdateRequest->SetURL(ApiUrl + "/updateGameSessionState");
			UpdateRequest->SetVerb("POST");
			UpdateRequest->SetHeader("Authorization", ServerPassword);
			UpdateRequest->SetHeader("Content-Type", "application/json");
			UpdateRequest->SetContentAsString(RequestBody);
			UpdateRequest->ProcessRequest();
		}
	}

#endif
}

I discovered that I get the id if there is max 1 concurrent server processes per instance, but whenever I turn it up to 2 or more, everyone gets “” (empty) Aws::GameLift::Server::GetGameSessionId().GetResult(), is this a gamelift bug? sure seems like it

Hi @patrick

Thanks for reaching out. I have cut a ticket for the gamelift team to look into this issue.

For now, you could potentially work around this issue by using multiple launch path/param instead of concurrent executions, for instance:

aws gamelift create-fleet --region $REGION \
--name "TestFleet" --ec2-instance-type c5.large  \
--ec2-inbound-permissions FromPort=6250,ToPort=6280,IpRange="0.0.0.0/0",\
Protocol=TCP FromPort=22,ToPort=22,IpRange="0.0.0.0/0",Protocol=TCP \
--build-id $BUILD_ID \
--runtime-configuration ServerProcesses="[{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6251 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6252 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6253 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6254 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6255 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6256 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6257 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6258 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6259 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6260 gameSessionLengthSeconds:10',ConcurrentExecutions=1}]"

#GLIFT-15121

I found out what it was all about. Game sessions had not yet started on the instance, it was idle waiting for a game session to start, but in the code, the call to “GetGameSessionIdOutcome.IsSuccess()” returned true even tho there was no game session active, which should for sure be changed as it does not make sense to call the function that when it should servere as a way to check if game sessions are active and can return an id…

Aha, makes sense. This behavior is intended. The request to call GetGameSessionId succeeded, but it returns no result.

We cannot modify this behavior nevertheless because that’d break backwards compatibility. I’ll create a task to make this behavior more clear in the docs.

https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-server-sdk-cpp-ref-actions.html#integration-server-sdk-cpp-ref-getgamesessionid
https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-server-sdk-csharp-ref-actions.html#integration-server-sdk-csharp-ref-getgamesessionid

GLIFT-15502