question

01markbryant01 avatar image
01markbryant01 asked

About Unity-specific GSDK

I'm trying to test my headless server made with unity3d to integrate it with the Multiplayer 2.0 version of Playfab using this Unity-specific GSDK and following this guide: https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/servers/locally-debugging-game-servers-and-integration-with-playfab. When I run it my server executable crash when the GSDK Start function gets called. It complains about a missing GSDK_CONFIG_FILE environment variable. Because the configuration file is generated dynamically this GSDK_CONFIG_FILE shouldn't also be setup dynamically?

10 |1200

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

Sarah Zhang avatar image
Sarah Zhang answered

Did you run the Unity server scene in the Unity Editor? If so, there will be this “Environment variable GSDK_CONFIG_FILE not defined” error, it’s normal. Only when you follow the guide completely and test the server build via MockVmAgent, the config file will be created dynamically. You can check the section Basic Setup, follow the prompts to do the setup before testing the server.

10 |1200

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

01markbryant01 avatar image
01markbryant01 answered

Thanks for taking your time to replay to me!. This is my current state:

Yes, I did what the Basic Setup tutorial suggested, when running with RunContainer = true; the PlayFabMultiplayerAgentAPI.Start() function crash due to the GSDK_CONFIG_FILE environment variable, when RunContainer = false, the server doesn't crash and the configuration variable is Ok as expected but the OnServerActiveCallback is never triggered. When ran, the MockVmAgent.exe remains in CurrentGameState: Initializing until it terminate due the time out.

Here is the code related to the GSDK initialization:

        private void Start()
        {
            var currentInGameSceneContainerIndex = GetArg("-mc", "-mapContainer") ?? "2";
            var mapContainer = LoadSceneManager.Instance.GetSceneContainerByIndex(System.Int32.Parse(currentInGameSceneContainerIndex));
            LoadSceneManager.Instance.SetCurrentSceneContainer(mapContainer);
            // if we are running a headless server just start the bolt server
            if (BoltNetwork.IsRunning)
                BoltNetwork.ShutdownImmediate();


            try
            {
                PlayFabMultiplayerAgentAPI.Start();
            }
            catch (System.Exception e)
            {
                Debug.LogError(e.Message);
            }
            PlayFabMultiplayerAgentAPI.IsDebugging = true;
            PlayFabMultiplayerAgentAPI.OnMaintenanceCallback += OnMaintenanceScheduled;
            PlayFabMultiplayerAgentAPI.OnShutDownCallback += OnShutdown;
            PlayFabMultiplayerAgentAPI.OnServerActiveCallback += OnServerActive;
            PlayFabMultiplayerAgentAPI.OnAgentErrorCallback += OnAgentError;


            EventHandler.RegisterEvent("OnPlayerDeployTriggered", OnReadyForPlayers);
            Debug.LogError("PlayFabMultiplayerAgentAPI started");
        }
        private void OnReadyForPlayers()
        {
            PlayFabMultiplayerAgentAPI.ReadyForPlayers();
            Debug.Log("ready for players");
        }
        private void OnAgentError(string error)
        {
            Debug.Log(error);
        }


        private void OnServerActive()
        {
            BoltLauncher.StartServer();
            Debug.LogError("Server Started From Agent Activation");
        }
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.

Sarah Zhang avatar image Sarah Zhang commented ·

I locally tested PlayFab Unity GSDK sample with "RunContainer = true;". It worked fine. If you want to set RunContainer = true; , apart from Basic Setup, you also need to follow this section Verifying containerization to do some additional operations. Have you followed this section? If so, and this issue still exists, could you provide more detailed error messages about it, like logs or a screenshot of PowerShell window? Please notice that hide your private information.

0 Likes 0 ·
01markbryant01 avatar image
01markbryant01 answered

Hey, @Sarah Zhang yes I did follow the Verifying containerization section word to word. About the log, when running the container using the power shell, show this:

Waiting for heartbeats from the game server.....

Container <container id> exited with exit code 1.

The funny thing is that into the OutputFolder the GameLog folder asociate with the container is always empty.

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.

mattdavidson2017 avatar image mattdavidson2017 commented ·

Did you ever figure out the problem? I am getting the same exact issue, and even had the exit code 1. It was due to a wrong file path in my MultiplayerSettings.json. After I fixed that, my server says "Waiting for heartbeats from the game server....." and does not update after that. I tried connecting from my client, no dice. It actually does have some output when I connect from a web browser though. Were you ever able to solve your issue?

0 Likes 0 ·
Farkas Szilard Levente avatar image
Farkas Szilard Levente answered

In case you run into issue with blocked at "Waiting for heartbeats from the game server.....":

  1. When building server from unity make sure "Server Build" is checked.
  2. Add -nographics -batchmode to server launch parameters.
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.