question

Niklas Gawell avatar image
Niklas Gawell asked

Unhandled error in PlayFabUnityHttp: System.IndexOutOfRangeException when invoking /Client/GetPlayerStatistics

We are using the PlayFabUnitySdk.

Occasionally we get an error when invoking /Client/GetPlayerStatistics. We have updated to the latest SKD version, but the problem persists. The line that breaks is

bool isGzipCompressed = responseBytes != null && responseBytes[0] == 31 && responseBytes[1] == 139;

I assume the problem is that responseBytes is shorter than 2. I do not see how we can handle this error in any way, as it is internal to the SDK. Below is the ErrorMessage we get. Please advise.

Unhandled error in PlayFabUnityHttp: System.IndexOutOfRangeException: Index was outside the bounds of the array.
\n  at PlayFab.Internal.PlayFabUnityHttp+<Post>d__12.MoveNext () [0x001c3] in PlayFabSDK\\Shared\\Internal\\PlayFabHttp\\PlayFabUnityHttp.cs:170
apisunity3d
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.

Niklas Gawell avatar image Niklas Gawell commented ·

We have also seen the same error on /Client/GetLeaderboardAroundPlayer

0 Likes 0 ·

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

We had a similar case like yours, and the root cause was probably due to packet loss, please take a look at this thread:

https://community.playfab.com/questions/39877/indexoutofrangeexception-when-calling-updateuserda.html

Currently the SDK doesn’t handle this situation very well, as a workaround, you can add few Conditional statements above the line that breaks to avoid the exception when responseBytes is shorter than 2.

2 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.

Niklas Gawell avatar image Niklas Gawell commented ·

So basically we should throw the response away and hope for a better response next time?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Niklas Gawell commented ·

Yes, that's right. You should have a retry mechanism when receiving invalid responses.

0 Likes 0 ·

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.