question

Damian Rajamanie avatar image
Damian Rajamanie asked

SerializationException: Invalid JSON string

Hi there,

We have encountered a big problem with ONE of our new players who is unable to run our game. ( we have had 100s of players through the system and never seen this before).

The error in his log is as in the title, here is the callstack:

SerializationException: Invalid JSON string at PlayFab.Json.PlayFabSimpleJson.DeserializeObject (System.String json) [0x0000c] in <39d418abd8274a0f8516d0ce771644aa>:0 at PlayFab.Json.PlayFabSimpleJson.DeserializeObject (System.String json, System.Type type, PlayFab.Json.IJsonSerializerStrategy jsonSerializerStrategy) [0x00000] in <39d418abd8274a0f8516d0ce771644aa>:0 at PlayFab.Json.PlayFabSimpleJson.DeserializeObject[T] (System.String json, PlayFab.Json.IJsonSerializerStrategy jsonSerializerStrategy) [0x00000] in <39d418abd8274a0f8516d0ce771644aa>:0 at PlayFab.Json.SimpleJsonInstance.DeserializeObject[T] (System.String json) [0x00000] in <39d418abd8274a0f8516d0ce771644aa>:0 at PlayFab.Internal.PlayFabUnityHttp.OnResponse (System.String response, PlayFab.Internal.CallRequestContainer reqContainer) [0x0002b] in <39d418abd8274a0f8516d0ce771644aa>: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__20:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

We normally handle errors nicely, but in this case we don't even get our success/failure callbacks and it falls over within the file:

PlayFabUnityHttp.cs - function OnResponse()We added some logging and was able to get the user to run a debug build for us and we printed out the response, our code added was:public void OnResponse(string response, CallRequestContainer reqContainer)
try
           {
#if PLAYFAB_REQUEST_TIMING
               var startTime = DateTime.UtcNow;
#endif
               if (response == null)
                   Debug.Log("Response is NULL");
               else
                   Debug.Log("Response is " + response);
               var serializer = PluginManager.GetPlugin<ISerializerPlugin>(PluginContract.PlayFab_Serializer);
               var httpResult = serializer.DeserializeObject<HttpResponseObject>(response);

....
}

The printed response is clearly not JSON, thought it seems like it's trying to deserialize it thinking it is JSON, here's what the response was:

Response is �Sێ�0�^�i��$D�C�66��R9ě`h@`�eW��:�U/R�Z�{�g���(e{d�p� ��qP�Jt��)G*��|Q6l���Vë́Lj��3=�*�,Ͷfs�j.Tc��U]]�l�@۰ԁ5�58�V���"-�jy�Mk�vך�{�!�p`�O@�v������XX��x�������ɣ���2Mص��Q�d�#mv'�Q]N���������qX �W�QH]?k}*άw�תd��U��%�۹ז��v����NY�A��S%��|B՜4�@ ��K

? Very odd to us.

At this point it looks like the try fails and is caught, which simply spews out the exception into the log but never gives us a failure so our game just hangs.

This is EXTREMELY strange. We have tracked it down to what we believe is the calling function that fails

void _loginWithSteam()
    {
        Debug.Log("#PLAYFAB# _loginWithSteam()");
        byte[] ticket = new byte[1024];
        uint ticketLength;
        HAuthTicket hTicket = SteamUser.GetAuthSessionTicket(ticket, ticket.Length, out ticketLength);
        Array.Resize(ref ticket, (int)ticketLength);
        // Convert bytes to string
        StringBuilder sb = new StringBuilder();
        foreach (byte b in ticket)
        {
            sb.AppendFormat("{0:x2}", b);
        }
        string hexTicket = sb.ToString();
        var request = new LoginWithSteamRequest { CreateAccount = true, SteamTicket = hexTicket };
        PlayFabClientAPI.LoginWithSteam(request, _onSteamLoginSuccess, _onSteamLoginFailure);
    }

We see that we enter this function, but we never have our prints from _onSteamLoginSuccess or _onSteamLoginFailure, so it looks like LoginWithSteam for this user is responding with that stuff above and is not making any sense to the Deserializer.

We would really appreciate some swift help on this as it's a live user who just got the game and we're actively trying to help him get into the game but it is just very alien.

I can and will provide any and all information you require :).

Our title ID is EAA9

Cheers

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.

jital avatar image jital ♦ commented ·

Hello,

Would you be able to provide the PlayFab ID for the affected player?

0 Likes 0 ·
Damian Rajamanie avatar image
Damian Rajamanie answered

The player's ID is: 347F9FBB0103B3CB

10 |1200

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

Damian Rajamanie avatar image
Damian Rajamanie answered

The player's ID is: 347F9FBB0103B3CB

10 |1200

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

Damian Rajamanie avatar image
Damian Rajamanie answered

Did anyone have any further knowledge about this?

3 comments
10 |1200

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

jital avatar image jital ♦ commented ·

I apologize for the lack of response,

We will need more information about this. Does this same issue occur if the request is made in Postman? Can you make this same request with the same user in Postman and post the request and response here.

If you do not have Postman set up for PlayFab information on how to do so can be found, here.

0 Likes 0 ·
Damian Rajamanie avatar image Damian Rajamanie commented ·

hmmm, this is a live user I don't know how I'd be able to get the same auth token from steam to simulate this

0 Likes 0 ·
jital avatar image jital ♦ Damian Rajamanie commented ·

To clarify, it does not need to be the exact user account, if you can reproduce the error with an account you control that works as well.

If this is not possible, would it be possible to capture the error with Fiddler or Wireshark? We're gonna need some debugging on the packet and/or JSON level to really see what's going on.

0 Likes 0 ·
esk avatar image
esk answered

The solution I finally figured out is to set "Accept-Encoding" to "identity" in the extraHeaders argument when calling ExecuteFunction. There seems to be some problem with the gzip encoding, hopefully the PlayFab team will figure it out as this seems to be an issue quite a few people are having. I was personally having this issue when developing locally, but now I seem to have it when using the cloud hosted Azure Functions directly too, and I don't know why!

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.