question

Jon avatar image
Jon asked

Unhandled OutOfRangeException

/CloudScript/ExecuteEntityCloudScript:
 Unhandled error in PlayFabUnityHttp: System.IndexOutOfRangeException: 
Index was outside the bounds of the array.   at 
PlayFab.Internal.PlayFabUnityHttp+<Post>d__12.MoveNext () 
[0x00000] in <00000000000000000000000000000000>:0    at 
UnityEngine.SetupCoroutine.InvokeMoveNext 
(System.Collections.IEnumerator enumerator, System.IntPtr 
returnValueAddress) [0x00000] in 
<00000000000000000000000000000000>:0

We see these sometimes happen for the player in our crash logs.

From older posts on the forum, it seems it is due to packet loss?

Does the SDK have any retry or we need to implement it ourselves? Also is there a way to tell if the playfab cloudscript was successfully executed based on the error?

In the case of this exception I posted above, it seems it was not actually successfully invoked as I cannot find it in the players data explorer when querying for it.

So if it never reached Playfab, then how come there can be a response where IndexOutOfRange gets thrown?

It would be good to be able to tell if the packet loss is on the request, or the response. That way we can decide whether to retry or not.

Thanks

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

·
Rick Chen avatar image
Rick Chen answered

According to this thread: https://community.playfab.com/questions/39877/indexoutofrangeexception-when-calling-updateuserda.html , the error could be due to the packet loss in the response. Currently, PlayFab doesn’t handle this error. You could use the try-catch statement in Unity to catch the error and retry the request.

As the packet of the response is lost, it is hard to know whether the CloudScript was successfully executed or not. You can set a marker in your CloudScript to mark whether the function was successfully executed. For example, at the end of the function, store a timestamp of the execution in the player data. And when you try the function again, you can firstly check the timestamp and decide whether it is valid to re-execute the function again.

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.

Jon avatar image Jon commented ·

Hi Rick, this exception isn't thrown by the SDK. It's caught and returned as `error` in the error callback already so it's hard to add any logic as it would require modifying SDK code.

We are using an older version of playfab though. I don't think the newer SDK update will "fix" this problem as playfab SDK does not handle retry, but it may have improve error logging, so I may try to upgrade.

But it seems the latest playfab SDK no longer supports compression of requests? PlayFabSettings.CompressApiData no longer exists either.

Do you know if there is a change log of playfab SDK changes?

Thanks

0 Likes 0 ·
Rick Chen avatar image Rick Chen ♦ Jon commented ·

>> this exception isn't thrown by the SDK.

It seems that the exception was thrown by the PlayFab SDK. From the line 4 of the error message you shown, the error occurred at PlayFab.Internal.PlayFabUnityHttp.

>> It's caught and returned as `error` in the error callback already so it's hard to add any logic as it would require modifying SDK code.

You don’t need to modify the SDK code, what I mean is to use the try-catch statement when calling the API. For example,

try
{
PlayFabCloudScriptAPI.ExecuteEntityCloudScript...
} catch (System.IndexOutOfRangeException e)
{
//retry logic here
}

>> But it seems the latest playfab SDK no longer supports compression of requests?

That could be because the Unity doesn’t support the data compression, you could refer to this thread: https://community.playfab.com/questions/51765/libcurl-bug-in-unity-202113f1.html

>> Do you know if there is a change log of playfab SDK changes?

In the past, there would be release note for new playfab UnitySDK version. Currently, there seems to be no release note. You can check the UnitySDK versions in this link: https://github.com/PlayFab/UnitySDK/releases

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.