question

jvluso avatar image
jvluso asked

Creating Playfab Multiplayer Server in Container mode for a Unity project

I am attempting to make a Playfab Multiplayer Server for a Unity game. When I try to add a standby server to the build, I see that it is unhealthy. I downloaded the LocalMultiplayerAgent to test locally, and when I do I get the following error:

fail: PlayFabLocalMultiplayerAgent[0]
      Exception encountered when creating image: System.TimeoutException: The operation has timed out.
         at System.IO.Pipes.NamedPipeClientStream.ConnectInternal(Int32 timeout, CancellationToken cancellationToken, Int32 startTime)
         at System.IO.Pipes.NamedPipeClientStream.<>c__DisplayClass20_0.<ConnectAsync>b__0()
         at System.Threading.Tasks.Task.InnerInvoke()
         at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
      --- End of stack trace from previous location where exception was thrown ---
         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
      --- End of stack trace from previous location where exception was thrown ---
         at Docker.DotNet.DockerClient.<>c__DisplayClass6_0.<<-ctor>b__0>d.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at Microsoft.Net.Http.Client.ManagedHandler.ProcessRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
         at Microsoft.Net.Http.Client.ManagedHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
         at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
         at Docker.DotNet.DockerClient.PrivateMakeRequestAsync(TimeSpan timeout, HttpCompletionOption completionOption, HttpMethod method, String path, IQueryString queryString, IDictionary`2 headers, IRequestContent data, CancellationToken cancellationToken)
         at Docker.DotNet.DockerClient.MakeRequestForRawResponseAsync(HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, CancellationToken token)
         at Docker.DotNet.Models.StreamUtil.MonitorResponseForMessagesAsync[T](Task`1 responseTask, DockerClient client, CancellationToken cancel, IProgress`1 progress)
         at Microsoft.Azure.Gaming.VmAgent.ContainerEngines.DockerContainerEngine.<>c__DisplayClass21_0.<<RetrieveResources>b__2>d.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at Polly.AsyncPolicy.<>c__DisplayClass40_0.<<ImplementationAsync>b__0>d.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at Polly.Retry.AsyncRetryEngine.ImplementationAsync[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Func`5 onRetryAsync, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider, Boolean continueOnCapturedContext)

My Local Multiplayer Agent configuration is

{
  "RunContainer": true,
  "OutputFolder": "",
  "NumHeartBeatsForActivateResponse": 10,
  "NumHeartBeatsForTerminateResponse": 60,
  "AgentListeningPort": 56001,
  "AssetDetails": [
    {
      "MountPath": "C:\\Assets",
      "LocalFilePath": "C:\\Users\\remy\\GoldenPath\\Builds\\server\\GoldenPath_server.zip"
    }
  ],
  "DeploymentMetadata": {
    "Environment": "LOCAL",
    "FeaturesEnabled": "List,Of,Features,Enabled"
  },
  "GameCertificateDetails": [],
  "PortMappingsList": [
    [
      {
        "NodePort": 56100,
        "GamePort": {
          "Name": "game_port",
          "Number": 7777,
          "Protocol": "TCP"
        }
      }
    ]
  ],
  "ContainerStartParameters": {
    "StartGameCommand": "C:\\Assets\\GoldenPath.exe -mlapi multiplayerServer -batchmode",
    "ResourceLimits": {
      "Cpus": 0,
      "MemoryGib": 0
    },
    "ImageDetails": {
      "Registry": "mcr.microsoft.com",
      "ImageName": "playfab/multiplayer",
      "ImageTag": "wsc-10.0.17763.3046",
      "Username": "",
      "Password": ""
    }
  },
  "SessionConfig": {
    "SessionId": "ba67d671-512a-4e7d-a38c-2329ce181946",
    "SessionCookie": null,
    "InitialPlayers": [ "Player1", "Player2" ]
  },
  "TitleId": "",
  "BuildId": "00000000-0000-0000-0000-000000000000",
  "Region": "EastUs"
}

My game gets to the section of code that readies and starts the server when I run it manually, but I don't think it gets there in the container because I can't see the debug logs anywhere, however this is the code:

        private void StartMultiplayerServer(){
            
            Debug.LogWarning("Starting the Multiplayer Server");
            PlayFabMultiplayerAgentAPI.Start();
            Debug.LogWarning("readying for players");
            StartCoroutine(ReadyForPlayers());
            Debug.LogWarning("adding server callback");
            PlayFabMultiplayerAgentAPI.OnServerActiveCallback += OnServerActive;
            Debug.LogWarning("starting the ngo server");
            NetworkManager.Singleton.StartServer();
        }
        private IEnumerator ReadyForPlayers()
        {
            yield return new WaitForSeconds(.5f);
            PlayFabMultiplayerAgentAPI.ReadyForPlayers();
        }
        private void OnServerActive()
        {
            Debug.Log("Server Started From Agent Activation");
            // players can now connect to the server
        }

unity3dmultiplayer
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

·
Gosen Gao avatar image
Gosen Gao answered

According to the error message, there should be an issue creating the image. Please follow Verifying containerization to make sure you have set up the Docker and LocalMultiplayerAgent properly and then try again

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.