question

george@thenuum.com avatar image
george@thenuum.com asked

Internal Server Error: Timeout

We are having a few timeouts with a cloudscript. We are wondering what we can do to fix this. The timeout doesn't happen with everybody, just like 5 times a day and the script runs probably like 1,000 times a day. We would still like it to work all the time.

The script is a reward system for hitting target in a certain order or at least getting a reward for hitting them all in the time limit. Is it a big O problem? The PlayerOwnsCosmetic() is a tough one because we have to go through the player's inventory to find if the player has the cosmetic. So I imagine players with big inventory might have the script take longer?

5640-image.png

5651-image.png

CloudScriptPlayer Inventory
image.png (128.3 KiB)
image.png (28.3 KiB)
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

·
Gosen Gao avatar image
Gosen Gao answered

As CloudScript timeout error mentioned, If you encounter this error, you can:

  1. break your CloudScript (Legacy) into smaller code segments which will run in under 4 seconds.

  2. Switch to CloudScript using Azure Functions, which has longer timeout limits in some cases.

Since it is not occurred frequently, you can also implement a retry mechanism in client to retry with an exponential delay back-off. For more info, you can refer to SDK error handling Best Practices - PlayFab | Microsoft Docs.

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.

george@thenuum.com avatar image george@thenuum.com commented ·

Will try the small break into smaller code segments and see how it goes thanks.

0 Likes 0 ·
george@thenuum.com avatar image george@thenuum.com george@thenuum.com commented ·

Ok so checking some of the functions that break. This one seems odd. I only update 3 stats and use update player statistic. Yet it fails. How can I break this down even more? Seems like a bug, I should be able to at least make one call after an IF statement check. I could return instead of if else. 5683-image.png 5677-image.png

0 Likes 0 ·
image.png (56.7 KiB)
image.png (23.2 KiB)
Gosen Gao avatar image Gosen Gao george@thenuum.com commented ·

It may happen that only calling one API still times out. If this problem does not occur frequently, it may be caused by cold start, refer to CloudScript execution time includes server warmup - Playfab Community. You can mitigate this kind of problem by using the retry mechanism I mentioned above.

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.