question

Kyle Meadows avatar image
Kyle Meadows asked

"Must call GetEntityToken" on server despite doing so.

This code was working a few months ago, but I haven't tried it since then. When the players are ready, I get the match for player info.

            if (!GameserverSDK.ReadyForPlayers())
            {
                Environment.Exit(1);
            }


            PlayFabResult<GetMatchResult> matchResult = null;


            GameserverSDK.LogMessage("Players ready: Getting player settings.");


            var task = Task.Run(async () =>
            {
                var entityResponse = await PlayFabAuthenticationAPI.GetEntityTokenAsync(new GetEntityTokenRequest());


                matchResult = await PlayFabMultiplayerAPI.GetMatchAsync(new GetMatchRequest()
                {
                    QueueName = "1v1",
                    MatchId = GameserverSDK.getConfigSettings()[GameserverSDK.SessionIdKey],
                    ReturnMemberAttributes = true
                });
            });


task.Wait();



            if (matchResult.Error != null) // Line 83  {
                GameserverSDK.LogMessage($"Could not get match: {matchResult.Error.GenerateErrorReport()}");
                GameserverSDK.LogMessage($"Session ID: {GameserverSDK.SessionIdKey}");
                return;
            } 

However, I get this error:

{"log":"Running Startup Script\n","stream":"stdout","time":"2020-07-01T09:03:35.1178936Z"} {"log":"Certificates located at: C:\\GameCertificates\n","stream":"stdout","time":"2020-07-01T09:03:36.4185173Z"} {"log":"\n","stream":"stderr","time":"2020-07-01T09:06:20.7354376Z"} {"log":"Unhandled Exception: System.AggregateException: One or more errors occurred. ---\u003e PlayFab.PlayFabException: Must call Client Login or GetEntityToken before calling this method\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"} {"log":" at PlayFab.PlayFabMultiplayerAPI.\u003cGetMatchAsync\u003ed__25.MoveNext()\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"} {"log":"--- End of stack trace from previous location where exception was thrown ---\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"} {"log":" at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"} {"log":" at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"} {"log":" at Empis.DedicatedServer.Playfab.Program.\u003c\u003ec__DisplayClass3_0.\u003c\u003cMain\u003eb__3\u003ed.MoveNext() in C:\\Users\\Kyle\\Documents\\Unity Projects\\empis\\Empis\\Empis.DedicatedServer.Playfab\\Program.cs:line 73\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"} {"log":" --- End of inner exception stack trace ---\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"} {"log":" at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"} {"log":" at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"} {"log":" at Empis.DedicatedServer.Playfab.Program.Main(String[] args) in C:\\Users\\Kyle\\Documents\\Unity Projects\\empis\\Empis\\Empis.DedicatedServer.Playfab\\Program.cs:line 83\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"}

It seems to not know I'm calling GetEntityTokenAsync().

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.

Kyle Meadows avatar image Kyle Meadows commented ·

Oops, I didn't know the log would look so messy. This is what I'm confused about: {"log":"Unhandled Exception: System.AggregateException: One or more errors occurred. ---\u003e PlayFab.PlayFabException: Must call Client Login or GetEntityToken before calling this method\r\n","stream":"stderr","time":"2020-07-01T09:06:20.9375087Z"}

0 Likes 0 ·

1 Answer

·
Seth Du avatar image
Seth Du answered

The header for the API GetEntityToken can be either session ticket or a secret key. In the server build, I believe you will need to manually set the server secret key to call GetEntityToken. Have you tried to configure secret key?

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.