question

Georg Laage avatar image
Georg Laage asked

Index out of range on legacy server heartbeat response

Hello together.

I currently face a randomy occuring error when sending a playfab heartbeat.
This boils down to the following line:

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

where it throws the following error:

 Unhandled error in PlayFabUnityHttp: System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at PlayFab.Internal.PlayFabUnityHttp+<Post>d__12.MoveNext ()

I tried to find a pattern with it but it just seems to randomly pop up. I send the heartbeat about every minute. this error occures every 6-9 heartbeats.
Mostly it works again if i just call another heartbeat but sometimes it ends in only invalid responses.

code to call the heartbeats:

var request = new PlayFab.ServerModels.RefreshGameServerInstanceHeartbeatRequest() { LobbyId = ID };
PlayFab.PlayFabServerAPI.RefreshGameServerInstanceHeartbeat( request, (PlayFab.ServerModels.RefreshGameServerInstanceHeartbeatResult r) => res = r, (PlayFab.PlayFabError _error) => { heartbeatError = true; error = _error; } );

thx in advance for any insight in this matter!

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

·
Citrus Yan avatar image
Citrus Yan answered

Referring to the source code in PlayFabUnityHttp.cs:

byte[] responseBytes = www.downloadHandler.data;

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

There is probably something wrong with the “responseBytes” byte array received from www.downloadHandler.data, would you please take a closer look at it when the error happens and share more details about it so we can investigate further?

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

Georg Laage avatar image Georg Laage commented ·

Hey, thx for the answer!
as to when this happens i can not say anything i'm afraid. As i said it feels like it's random. I just have a coroutine running that sends the request every 60 seconds.

a small check revealed: Every 4-6 times the response has the length 0. (As kind of expected that it's 0) Other then that i'm not sure as to what i could do or check for further investigation of this problem.

If you have an idea about a piece of information that might be helpful here i'd be happy to provide it.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Georg Laage commented ·

So you mean www.downloadHandler.data has a length of 0 however it's not null, is that right?

0 Likes 0 ·
debug.png (49.0 KiB)
debug.png (54.3 KiB)
Georg Laage avatar image Georg Laage Citrus Yan commented ·

yes that is correct:

0 Likes 0 ·
error-snapshot.png (56.8 KiB)
Citrus Yan avatar image Citrus Yan Georg Laage commented ·

And, it would helpful if you can share some repro steps (code examples) for us to investigate.

0 Likes 0 ·
Georg Laage avatar image Georg Laage Citrus Yan commented ·

okay i will check if i can recreate an empty project producing this error.

1 Like 1 ·
Show more comments

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.