question

Nikita Klimov avatar image
Nikita Klimov asked

InternalError while http.request to server from CloudScript.

We get an Internal Error when sending data from CloudScript:

"result":
{
    "responseContent": null,
    "httpStatus": null,
    "httpStatusCode": 0,
    "requestError": "InternalError"
}

Cloud Script code:

// Function URL
handlers.SendToElasticSearch = function(args, context)
{
	// Build Request
	var Content     = JSON.stringify(args.Data);
	var HTTPMethod  = "POST";
	var ContentType = "application/json";
	
	try
	{
		return http.request("http://.../receive", HTTPMethod, Content, ContentType);
	}
	catch (err)
	{
		return {Error: err};
	}
}

What could be the problem?

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

Seth Du avatar image Seth Du ♦ commented ·

Can you test the custom http request in some testing tool like Postman? What's the estimated response time?

In addition, What's the title ID?

0 Likes 0 ·
Nikita Klimov avatar image Nikita Klimov Seth Du ♦ commented ·

ExecutionTimeSeconds ≈ 0.42.

ProcessorTimeSeconds ≈ 0.0017.

Our Title ID: E06B

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Nikita Klimov commented ·

I have checked your title and there is only 1 DownstreamServiceUnavailable error for ExecuteCloudScript API call. Please note that HTTP or RESTful API cannot guarantee 100% success. Please add retry sentences if possible. Otherwise, it will require the client to call again.

0 Likes 0 ·
Show more comments

1 Answer

·
Seth Du avatar image
Seth Du answered

I have checked all API calls in last 2 days and the error rate is below 0.03 and Gateway Timeout is the error message. As this document 504 Gateway Timeout, I don't think there is direct or quick fix from PlayFab side. I suggest having a stress test of this HTTP request outside Cloud Script so that you can reduce the error occurrence. If it is a network issues from Cloud Script, you may need to switch to Azure Function, as you may switch the regions that host functions. Otherwise, adding retry mechanism in your code should work fine.

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.