question

acrobatepee avatar image
acrobatepee asked

HTTP.REQUEST returning CloudScriptHTTPRequestError even if it goes through

Hello ! I am sending an http.request to an API that I know is reliable and works. When going through Postman, everything goes through and I receive the response. When going through Cloudscript and logging the request directly, it also returns me the response, but it also errors at the same time and prevents the function from continuing.

Below is the request and the error code it returns (please keep in mind that it is logging the correct response and is perfectly working on the APIs side, just erroring on Playfab and breaking my handler) :

var url = "validurl"
    
        var method = "post";
        
        var body = {
            
            wax_account: String(playersToSendTokenWAX), // Receiver Accounts
            quantity: tokenRewardQuantityWAX , // Amount of WAX to be sent
            memo: args.situation // Memo for the transaction, needs to be in even if empty
        };
            
        var content = JSON.stringify(body);
                        
        var contentType = "application/json";
            
        var headers = {
            Authorization: "ithasonebutnotsharingit"
        };
        
        var responseTokenWAX = http.request(url,method,content,contentType,headers); // Send Tokens (ERROR IS HERE)
        globalResponse['responseTokenWAX'] = JSON.parse(responseTokenWAX);
    }
"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.Testing (9CE70-main.js:232:37)\n    at Object.invokeFunction (Script:117:33)"
        }
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.

Xiao Zha avatar image
Xiao Zha answered

You can use Azure Function instead of Cloud Script for it can provide you much longer-running, asynchronous and free from the API count limit calls, and that’s also the method we recommend to use. If you want to extend the Cloud Script execution time limit, you would need to upgrade to enterprise account, starting at $10k per month, if you need you can contact the sales team for details.

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.

acrobatepee avatar image acrobatepee commented ·

Thanks for your answer, so I should use this correct ? Also, what's the timeout limit on those then ? And how can it be adjusted ?

I'm sometimes looking at 10s and really need this to be able to take it.

Thanks in advance

0 Likes 0 ·
acrobatepee avatar image acrobatepee commented ·

Would also like to know how can I call these functions from CloudScript ? I still need cloudscript to get a few infos from me before I call those, and if I call them via HTTP they will just timeout again.

Thanks in advance

0 Likes 0 ·
acrobatepee avatar image
acrobatepee answered

After analyzing a bit more, I think the 2.5s timeout on external requests is what is causing my issues. The request does get processed by the API but Playfab times out before it can get the response.

Can we increase that timeout somehow ? (The options in the settings don't have that case)


Thanks in advance.

10 |1200

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

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.