question

madmojoman avatar image
madmojoman asked

Server Termination with MpsSamples UnityMirror Sample

Following the start-up guide process for the MpsSamples UnityMirror client and server project:

I setup everything properly with Docker so I could test out the client server connection locally. After I followed the steps labeled for starting the server, verified that the heartbeat shows it is Active, then start the client...it connects up, the PlayFab account is created with the silent authorization based on the device id, the client UI is updated to show that I've successfully connected and with the new account's PlayFabId displayed. Then, after about 30-60 seconds the client shows a message that the server is terminating and the client is disconnected.

In the guide it states:

If the GSDK is integrated correctly, LocalMultiplayerAgent prints the following outputs: CurrentGameState - Initializing (this is optional and may not show up if your game server directly calls GSDK::ReadyForPlayers and does not call GSDK::Start) CurrentGameState - StandingBy CurrentGameState - Active CurrentGameState - Terminating If the shutdown callbacks are set up correctly, your game server exits soon after the state is set to terminating. It is important to verify that the game server exits to avoid ungraceful shutdowns on the PlayFab platform.

I've verified this happens. I did more research on this and found that the MultiplayerSettings.json has NumHeartBeatsForActivateResponse and NumHeartBeatsForTerminateResponse. After NumHeartBeatsForActivateResponse heartbeats, LocalMultiplayerAgent requests the game server to move from standby to active. Then after NumHeartBeatsForTerminateResponse heartbeats LocalMultiplayerAgent requests the game server to move from active to terminated.

Is this MultiplayerSettings.json only used for local testing?

When I setup the server on PlayFab, it won't be terminating the server after # of heartbeats anymore, right?

And for local testing purposes, do I just need to set NumHeartBeatsForTerminateResponse to some really high amount so that I can test server-client messaging for different features properly without it just terminating? Or is there a way to disable it so that it will transition to terminating only once no clients are connected anymore?

Custom Game Servers
10 |1200

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

1 Answer

·
Rick Chen avatar image
Rick Chen answered

Yes. This config file is part of the local debugging toolset. It won’t affect the PlayFab Multiplayer server. For local testing, you could just set NumHeartBeatsForTerminateResponse to a high value to make the session longer.

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.

Paul Gilmore avatar image Paul Gilmore commented ·

Greetings from PlayFab!

We understand that not all the options in MultiplayerSettings.json are well understood. We have recently made a tool to try and improve this. Please take a look: GitHub.com/PlayFab/LocalMultiplayerAgent/SettingsJsonGenerator

This utility has sliders and defaults for NumHeartBeatsForActivateResponse and NumHeartBeatsForTerminateResponse. These defaults and sample ranges should give you a sense of some time thresholds you might expect in the live cloud environment. It's still possible that real values might be outside these ranges, but your server should handle these ranges as "typical".

0 Likes 0 ·

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.