question

Jeremey Zela avatar image
Jeremey Zela asked

Transition from Active to Standby

Hi there, I'm new to playfab and have a question/problem. I have a test UE4 dedicated server that I'm able to successfully deploy and connect to with multiple clients. All my current interactions with GSDK seem to work fine. For example, when I connect or disconnect from the server with a client - the players statistics for the server are updated correctly on the playfab web portal.

The one issue I'm having, however, is when I disconnect all clients and terminate the server (FGenericPlatformMisc::RequestExit) my server never transitions to Standby in the web portal. It just remains active - but isn't functional because the gameserver exe has been terminated.

Please advise. Thanks!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rick Chen avatar image
Rick Chen answered

Could you provide a code snippet of the shut down module and logs of your server? Usually the server instance will shut down if GSDK no longer provides a heartbeat. Did you follow this document: Integrating the PlayFab GSDK into Unreal Engine 4 to set up GSDK?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeremey Zela avatar image
Jeremey Zela answered

@Junjin Chen Thanks for you reply! I have used that document, the unreal plugin from the gsdk github and also information from various posts to get to where I am now.

I have code in my gamemode that is what terminates the server when there is only one player left (this last player is the server itself).

void APlayFabTesterGameModeBase::Logout(AController* Controller)
{
   if (GetNumPlayers() == 1) {
      FTimerHandle UnusedHandle;
      GetWorldTimerManager().SetTimer(UnusedHandle, this, &APlayFabTesterGameModeBase::ShutdownServer, 5.0f, false);
   }
   else {
      UE_LOG(LogTemp, Warning, TEXT("STILL HAS PLAYERS ON LOGOUT"));
   }
}

void APlayFabTesterGameModeBase::ShutdownServer()
{
    FGenericPlatformMisc::RequestExit(false);
}

As far as logs go, I see the vmagent log is churning this message every 30 seconds:

2020-10-14 10:42:43.708 +00:00 [Information] Sending heartbeat with correlationId: f6498d19-c52f-4a81-9290-ca4e6a7d31c2, body: {"vmState":"Running","assignmentId":"ffffffff-ffff-ffff-01dd-070000000000:c129bd40-e0e2-45f0-b312-6bdddef0dbd8:EastUs","sessionHostHeartbeatMap":{"6221eec4a5313c2ad4888e9527efda8aa68977ede78578499d3b8776e6faffa4":{"currentGameState":"Active","nextHeartbeatIntervalMs":1000,"operation":"Continue","lastStateTransitionTimeUtc":"2020-10-13T11:43:53.8873886Z","sessionConfig":{"sessionId":"d1a87d8d-a3ea-4abe-bd31-a3565e201129"},"portMappings":[{"publicPort":30000,"nodePort":30000,"gamePort":{"name":"ue_game","number":7777,"protocol":"UDP"}}],"assignmentId":"ffffffff-ffff-ffff-01dd-070000000000:c129bd40-e0e2-45f0-b312-6bdddef0dbd8:EastUs"},"sequenceNumber":15,"agentProcessGuid":"bd5b2f0c-d88d-403b-9c2a-779a658d45c5","isUnassignable":false}

But in my gsdk log and game server log I'm showing that i terminated using the code above many hours ago (yesterday actually). Also, I don't see my game server is the process list on the server.

[2020.10.13-11.46.51:538][354]LogExit: Exiting.
[2020.10.13-11.46.51:548][354]Log file closed, 10/13/20 11:46:51
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rick Chen avatar image Rick Chen ♦ commented ·

The FGenericPlatformMisc::RequestExit is a request and sometimes could be stuck. You could try forcing the exit by changing the ‘false’ to ‘true’. You could also add a monitor process that checks if the server is idled for long time, then use other methods to force shutdown.

You can refer to this thread: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/52562-c-quit-game

0 Likes 0 ·
Jeremey Zela avatar image
Jeremey Zela answered

Using force = 'true' on RequestExit did indeed workaround this issue. If I find out any more information on why it needs to be forced, I will post back here. Thanks!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.