question

junpei.tamai@hautecouture.jp avatar image
junpei.tamai@hautecouture.jp asked

ExecuteCloudScript is behaving strangely.

I am using CloudScript (LEGACY).

Is there any difference between selecting a user in GameManager and executing CloudScript and executing CloudScript using ExecuteCloudScript?

Within CloudScript, we use http.request to call an external API, but when we execute CloudScript using ExecuteCloudScript, the call takes longer and causes a TimeOut error.


I am using translation software because my English is not good. Please let me know if it is difficult to understand.

CloudScriptgame manager
10 |1200

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

Xiao Zha avatar image
Xiao Zha answered

The two ways of calling CloudScript you mentioned don't make much difference in cloud script execution time and will generate the same PlayStreamEvent.

And there had an incident https://status.playfab.com/incidents/p43j79cfw9vq , which may be related to the issue you experienced. But it has been resolved. If you still have the issue to call ExecuteCloudScript API, please feel free to let us know.

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.

Thank you for your answer. I have used ExecuteCloudScript to run a CloudScript that calls http.request, but the problem still does not seem to be resolved. I get a timeout error.

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha junpei.tamai@hautecouture.jp commented ·

Could you please provide detailed error message and the Cloud Script for us to research? Please remember to remove the personally identifiable information. Also, the http.request call timeout is 2.5 seconds, if your service does not return within that period, the call will timeout, causing the script to fail. So, you may test this request with some other tools like postman to see if it works well.

0 Likes 0 ·
junpei.tamai@hautecouture.jp avatar image
junpei.tamai@hautecouture.jp answered

Requesting the API directly with a tool like postman works fine. Response time is about 0.5 seconds.

However, if you implement the API in CloudScrpt and make a request with ExecuteCloudScript, you will get a timeout error.

▼CloudScript

   handlers.logTest = function (args, context) {
             var url = "https://exsample";
             var method = "get";
             var contentBody = "";
             var contentType = "application/json";
             var headers = {};
        
             var response = {}
             response = http.request(url, method, contentBody, contentType, headers, true);
             return response;
         };

▼Error

 {
     "code": 200,
     "status": "OK",
     "data": {
         "FunctionName": "logTest",
         "Revision": 397,
         "Logs": [
             {
                 "Level": "Error",
                 "Message": "HTTP request error",
                 "Data": {
                     "url": "https://exsample",
                     "method": "get",
                     "content": "",
                     "contentType": "application/json",
                     "headers": {},
                     "result": {
                         "responseContent": null,
                         "httpStatus": null,
                         "httpStatusCode": 0,
                         "requestError": "Timeout"
                     },
                     "httpRequestError": "Timeout"
                 }
             }
         ],
         "ExecutionTimeSeconds": 2.5040177,
         "ProcessorTimeSeconds": 0.004402,
         "MemoryConsumedBytes": 11384,
         "APIRequestsIssued": 0,
         "HttpRequestsIssued": 1,
         "Error": {
             "Error": "CloudScriptHTTPRequestError",
             "Message": "The script made an external HTTP request, which returned an error. See the Error logs for details.",
             "StackTrace": "Error\n at Object.http_request (Script:226:28)\n at Object.request (Script:265:35)\n at handlers.logTest (8686D-CloudScript.js:86:25)\n at Object.invokeFunction (Script:117:33)"
         }
     }
 }
5 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.

Xiao Zha avatar image Xiao Zha commented ·

The issue is that the http.request call timeout is 2.5 seconds. As I mentioned above, the http.request call timeout is 2.5 seconds in CloudScript, if your service does not return within that period, the call will timeout, causing the script to fail.

Also, I have checked the ExecuteCloudScript API call in your Title and found that the number of Timeouts has now returned to the state before the incident. If you feel that the number of Timeouts is too many, we recommend using AzureFunction(https://learn.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/), which supports asynchronous operations and has longer execution time.

0 Likes 0 ·
junpei.tamai@hautecouture.jp avatar image junpei.tamai@hautecouture.jp Xiao Zha commented ·

ExecuteCloudScript causes a timeout error in 2.5 seconds, but the same API at https://developer.playfab.com/ja-jp/r/t/titleid/players/playfabId/cloudscript returns a response in 0.5 seconds. http.request returns a response in 0.5 seconds, so I don't know how to solve the problem.

We would like to further investigate the solution to this problem as it is difficult to use Azure Functions in our project.

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha junpei.tamai@hautecouture.jp commented ·

Since you are requesting an external API, the time required for this request is uncontrollable. Does every time you call the API to execute the cloud script, it will time out, but every time you execute the cloud script in the GM player panel, it will not time out?

Since theoretically the performance of these two methods for executing cloud scripts should be similar, we would like to know the difference in the frequency of timeout occurrences when executing cloud scripts using these two methods.

You can use these two methods multiple times (about dozens of times) to execute cloud scripts, and then check the player_executed_cloudscript event in Data Explorer to get the frequency of timeout occurrences (events may be delayed).

Since the events generated by these two methods are the same, you can distinguish the events generated by these two methods by setting different parameters and logging them when using the two methods and. Please remember to set GeneratePlayStreamEvent parameter to true when you call ExecuteCloudScript API.

0 Likes 0 ·
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.