An AWS service call has failed when calling AcceptPlayerSession in Unreal Engine

Hi,

I’m trying to integrate GameLift into an Unreal Engine game and I’m hitting into an issue when calling Aws::GameLift::Server::AcceptPlayerSession. The outcome success is false and the error message I receive is

An AWS service call has failed. See the root cause error for more information.

This is using the GameLift Server SDK in Unreal Server 4.14.1, I have overridden the PreLogin method for our AGameMode class (see following)

    void AMyProjectGameMode::PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage)
{
#if WITH_GAMELIFT
if (FParse::Param(FCommandLine::Get(), TEXT("GAMELIFT")))
{
FString playerSessionId = UniqueId.ToString();
UE_LOG(LogMyProject, Log, TEXT("AMyProjectGameMode::PreLogin: Checking player with PlayerSessionId: %s"), *playerSessionId);
Aws::GameLift::GenericOutcome connectOutcome = Aws::GameLift::Server::AcceptPlayerSession(TCHAR_TO_ANSI(*playerSessionId));
if (!connectOutcome.IsSuccess())
{
ErrorMessage = connectOutcome.GetError().GetErrorMessage();
UE_LOG(LogMyProject, Log, TEXT("AMyProjectGameMode::PreLogin: Client connecting with invalid GameLift PlayerSessionId: %s, Error: %s"), *playerSessionId, *ErrorMessage);
}
}
#endif
}

Is there a way to get the root cause error information in code, or elsewhere? Is there anything wrong with the code I’m calling?

Hi @Alistair

GameLift just release GameLiftLocal. I believe this could help you test this use case locally!
Please see this forum post for more details!

Hi @Alistair

The code looks fine to me. Is there any
reasons why you are calling directly into the C++ sdk and not using the Unreal
plugin? That way, you would get to use Unreal types directly.
It would look something like this:


//Getting the module first.
FGameLiftServerSDKModule* gameLiftSdkModule = &FModuleManager::LoadModuleChecked<FGameLiftServerSDKModule>(FName("GameLiftServerSDK"));
FGameLiftGenericOutcome outcome = gameLiftSdkModule->AcceptPlayerSession(*playerSessionId);

As you surely know, the sdk and Unreal plugin
are available for download from here.

To your first question: There is currently no
way to get more information on the failure from the SDK.

But, in order for the AcceptPlayerSession call
to succeed, the player session created on GameLift must be in the ‘Reserved’
state. GameLift creates the PlayerSession in that state. The PlayerSession
expires after 60 seconds. This means that your game client must connect to your
server which would trigger the call to AcceptPlayerSession within 60 seconds of
the PlayerSession creation.

So, without knowing more about this specific
use case, I would make sure that:
1- The PlayerSession is created on GameLift before connecting to your server.

2- No longer than 60 seconds has passed since
its creation

Does this help?

Thanks, turns out I was missing the CreatePlayerSession step, I’ve done that now and managed to get the client in successfully.

Thanks, that’s really made things a lot easier and a lot quicker to test changes

@Alistair @Gelinotte

How does one actually pass the playerSessionId to the UniqueID of the Prelogin function?

I’m using FlexMatch and can get the PlayerSessionId from the match data returned back to the game client. I can then call ClientTravel with the returned ip and port but don’t know how to pass the playerSessionId now to the server to verify the connection.

Any help would be appreciated!