question

tweekley5 avatar image
tweekley5 asked

GetMatch API Returns NullReferenceException

I am getting a NullReference Exception when trying to use the GetMatchAPI. It seems to appear when I am trying to create a request. Here is the code for that:

 _token = response.EntityToken;
         Debug.Log("Entity token: " + response.EntityToken);
    
         GetMatchRequest getMatchRequest = new GetMatchRequest();
         getMatchRequest.MatchId = PlayFabMultiplayerAgentAPI.SessionConfig.SessionId;
         getMatchRequest.QueueName = "TestQueue";
         getMatchRequest.ReturnMemberAttributes = true;
         Debug.Log("After members");
         getMatchRequest.AuthenticationContext.EntityId = PlayFabSettings.staticSettings.TitleId;
         getMatchRequest.AuthenticationContext.EntityType = "title";
         getMatchRequest.AuthenticationContext.EntityToken = _token;
         PlayFabMultiplayerAPI.GetMatch(getMatchRequest, OnGetMatchResult, OnGetMatchError);

Here is the error I am getting: Title ID: this was sanitized Before GetEntityToken Call Timer:1.000043 - Max:1 state: PlayFab.MultiplayerAgent.Model.HeartbeatRequest, payload: {"CurrentGameState":"Active","CurrentGameHealth":"Healthy","CurrentPlayers":[]} Operation: Continue, Maintenance:, State: Active Entity token: this was sanitized After members NullReferenceException: Object reference not set to an instance of an object at BackfillServerTicket.OnGetServerEntityToken (PlayFab.AuthenticationModels.GetEntityTokenResponse response) [0x00084] in <cf264fc33ed64ce99d7c1caa09115149>:0 at PlayFab.Internal.PlayFabHttp+<>c__DisplayClass23_0`1[TResult].<MakeApiCall>b1 () [0x00008] in <24bbdf38737b4ec2b547ad514383d52d>:0 at PlayFab.Internal.PlayFabUnityHttp.OnResponse (System.String response, PlayFab.Internal.CallRequestContainer reqContainer) [0x000a7] in <24bbdf38737b4ec2b547ad514383d52d>:0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) PlayFab.Internal.PlayFabUnityHttp:OnResponse(String, CallRequestContainer) PlayFab.Internal.<Post>d_12:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at /home/bokken/build/output/unity/unity/Runtime/Export/Scripting/Coroutines.cs:17)

You can see it appears when I get to the getMatchRequest.AuthenticationContext portion of the request I am creating. I am using Unity PlayFab SDK version 2.159.230220.

apissdksCustom Game ServersMatchmaking
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

·
tweekley5 avatar image
tweekley5 answered

Solved it. Needed to instaniate AuthenticationContext.

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.