question

mlazowski avatar image
mlazowski asked

Http request call timeouts

Hello.

We are sometimes experiencing http timeouts when calling our API through cloudscript. This is a http error returned, not a cloud script execution time error.. We've checked and it's not our api returning a timeout.

Is there a way to increase the waiting time for http calls? If we wanted to purchase the extension for cloud script runtime, would that extend the timeouts for http calls as well?

If this is a problem on our end, any advice is appreciated.

Here's my call through cloud script.

let urlPod = baseAccountUrl + "pod/" + podId +apiKey; 
let body = {WorldId: activeWorldId, LayerId: playerData["layer"]["Value"], AreaId: playerData["area"]["Value"], X: x, Y: y };
      
http.request(urlPod, "put", JSON.stringify(body), 'application/json', headers);

Here's the error, with the API adress changed for security reasons. As you can see, the script ended after 2 seconds??

{
    "EventName": "player_executed_cloudscript",
    "Source": "CloudScript",
    "FunctionName": "PlaceMine",
    "CloudScriptExecutionResult": {
        "FunctionName": "PlaceMine",
        "Revision": 445,
        "FunctionResult": null,
        "FunctionResultTooLarge": null,
        "Logs": [
            {
                "Level": "Info",
                "Message": "{\"WorldId\":\"454b9feb-5970-40bf-89f6-58b13f563f14\",\"LayerId\":30,\"AreaId\":2,\"X\":1,\"Y\":11,\"Mode\":1,\"Type\":0,\"State\":2,\"Value\":0,\"StateExpiration\":\"2018-10-18T09:00:14.529Z\"}",
                "Data": null
            },
            {
                "Level": "Error",
                "Message": "HTTP request error",
                "Data": {
                    "url": "http://myapilink.net/api/1/pod/4d5ce737-9503-4134-b6a5-b2c28d37b6b2",
                    "method": "put",
                    "content": "{\"WorldId\":\"454b9feb-5970-40bf-89f6-58b13f563f14\",\"LayerId\":\"30\",\"AreaId\":\"2\",\"X\":1,\"Y\":11}",
                    "contentType": "application/json",
                    "headers": {
                        "PlayfabId": "F9549735E56B5591"
                    },
                    "result": {
                        "responseContent": null,
                        "httpStatus": null,
                        "httpStatusCode": 0,
                        "requestError": "Timeout"
                    },
                    "httpRequestError": "Timeout"
                }
            }
        ],
        "LogsTooLarge": null,
        "ExecutionTimeSeconds": 2.6625984,
        "ProcessorTimeSeconds": 0,
        "MemoryConsumedBytes": 85952,
        "APIRequestsIssued": 2,
        "HttpRequestsIssued": 4,
        "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 handlers.PlaceMine (7BC8-CloudScript.js:971:12)"
        }
    }
apisCloudScript
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

·
JayZuo avatar image
JayZuo answered

Based on where your Cloud Script function is called, the execution time limit is different. You can find this limit in Settings → Limits in the Game Manager. For API call, it's Cloud Script execution time (API call) and for triggered action, it's Cloud Script execution time (triggered action). You can also use Settings page to change the limit.

However, If you run out of this execution time, you should get a CloudScriptExecutionTimeLimitExceeded error. But you've got a CloudScriptHTTPRequestError which means there is an error happened in your http.request. And according to the log, it's your HTTP request timeout.

The issue is that 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.

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

mlazowski avatar image mlazowski commented ·

Hey @JayZuo, thanks for your response.

This is an API call and my current limit is 4,5 seconds. But the execution stopped at 2,6. As for the request being invalid, I have it on a loop if it fails and it does come through after some tries. Sometimes it works without problems at all. I've had this situation with multiple different requests to my other API.

What does this timeout error message actually mean? That the request timed out with no response (after how many seconds?) or that the request returned a timeout error from the call? Is there any way to increase the waiting time in a http request?

(Note to mods: Please disregard/delete the message I mistakenly added as an answer)

0 Likes 0 ·
JayZuo avatar image JayZuo ♦ mlazowski commented ·

The timeout error message means there is a "Timeout" error happened when Cloud Script try to call your url "http://myapilink.net/api/1/pod/4d5ce737-9503-4134-b6a5-b2c28d37b6b2". I'd suppose this is because the request timed out with no response. Maybe you can test this request with some other tools like postman to see if it works well. Besides, core PlayFab service is hosted in AWS US West 2 (Oregon), you may check if there is any network issue between AWS server and where your API is hosted.

0 Likes 0 ·
mlazowski avatar image mlazowski JayZuo ♦ commented ·

I did test the request with tools and it succeeded every single time.

What is the default waiting time for the request called from Cloud Script?

Is there a way to increase it?

Usually it takes 1.5-4 seconds to complete the request when using other tools to call it.

The api that takes the request has a timeout of 60 seconds, so it's not sending that message.

The server is in the UK so latency is to be expected, but timing out after 2 seconds is a bit too harsh in my opinion.

This is crucial for our game to work and we're willing to pay to increase this time, we just need to know what to increase.

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.