question

brandon@uprootstudios.com avatar image
brandon@uprootstudios.com asked

Unable to call ExecuteCloudScript from Thunderhead server

Hi, when using the Server API, our server build can call PlayFabServerAPI.ExecuteCloudScript() just fine when running locally. However, when running the exact same build in a Thunderhead VM, we get the error "/Server/ExecuteCloudScript: Unknown Error" and the Cloud Script is never called. We're using the PlayFab Unity SDK and have the Server API enabled for our server builds.

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

brandon@uprootstudios.com avatar image brandon@uprootstudios.com commented ·

Further information:

The exact code of the method call:

PlayFabServerAPI.ExecuteCloudScript(new ExecuteCloudScriptServerRequest{
    FunctionName = "validateWinner",
    FunctionParameter = results.Select(item => new {
        ID = item.Key, SCORE = item.Value
    }),
    PlayFabId = playerScoreList[0].PlayFabID
},
result => {
    Debug.Log ("SCRIPT RESULT OK: " + result.ToJson().ToStrnng());
}, 
error => {
    Debug.LogWarning("CLOUD SCRIPT ERROR: " + error.ToString());
});

This call works perfectly when running both inside the PlayFab MockVMAgent and running the server executable directly. However, when running it in Thunderhead the only error is:

/Server/ExecuteCloudScript PlayFabError(ServiceUnavailable, Unknown Error, 400 BadRequest)

According to this post it is a rare issue, however it happens on every single server instance we've run (we have so far tested over 50 instances with 100 clients in 1v1 games).

EDIT: I can also confirm that it happens on the latest SDK

0 Likes 0 ·
jital avatar image jital ♦ commented ·

Greetings,

This is something we are currently looking to with the new Unity SDK. Would you be able to provide your TitleID and any other pertinent information you think would be helpful?

0 Likes 0 ·
brandon@uprootstudios.com avatar image brandon@uprootstudios.com jital ♦ commented ·

@jital Sure, the TitleID is E39D6. Is there a reason why this wouldn’t be supported?

Also, I currently have no builds set up (as they use up our evaluation hours when not in use), but can create a new one if needed for testing

EDIT: I can also now confirm that this happens on both linux and windows VMs inside thunderhead

0 Likes 0 ·
ravarna avatar image ravarna brandon@uprootstudios.com commented ·

@Brandon Phillips are you able to call any Server API on Thundehead VMs? Are you having issues only with executing cloud script? That would be helpful information for us to debug.

0 Likes 0 ·
brandon@uprootstudios.com avatar image brandon@uprootstudios.com commented ·

Is there any resolve or update to this issue? If the Server API is not supported in Thunderhead, is there an alternative way of executive cloud script from a Thunderhead server?

0 Likes 0 ·
brandon@uprootstudios.com avatar image
brandon@uprootstudios.com answered

@ravarna @Brendan I solved it! Installing curl to the container when building the container image fixes the issue and the Server API now runs as expected in Thunderhead (Linux).

Explanation:

I noticed that calls to the Server API would fail in a Linux-based container on my local machine as well as in Thunderhead (although not in Windows-based containers on my local machine). After trying to POST to the API myself using UnityWebRequest, I noticed that it produces the same "Unknown Error" when running in the container. As it turns out, both HttpWebRequest and UnityWebRequest (when using HTTPS) rely on Unity correctly setting up the certificate from the system, and produce "Unknown Error" when the cert isn't found.

I first attempted to symlink the cert inside the Ubuntu container, although that did not work. Then I learned that Unity-based execs use the system's installation of curl, which ubuntu containers don't have pre-installed. Installing curl will also (seemingly) link the correct location of the SSL cert needed for HTTPS calls to succeed when using WebRequest.

I'm not sure if there is a similar solution for Windows-based containers, although I would imagine that it is a similar problem in-that Windows Server Core is likely missing a default cert or policy that exists in home installs of Windows.

For anyone else experiencing similar issues and using docker to build their linux-based containers, add these lines to your Dockerfile:

RUN apt-get -y update
RUN apt-get -y install curl wget
10 |1200

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

brendan avatar image
brendan answered

The "Unknown Error" you're getting is unrelated to the "ServiceUnavailable" error from the other thread you linked. Can you confirm what version of the GSDK you're using?

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.

brandon@uprootstudios.com avatar image brandon@uprootstudios.com commented ·
@Brendan

It is the C# GSDK version 0.9.190509.

@ravarna All calls to the Server API return the same error (when running in Thunderhead):

/Server/GetUserAccountInfo PlayFabError(ServiceUnavailable, Unknown Error, 400 BadRequest)

/Server/GetUserInventory PlayFabError(ServiceUnavailable, Unknown Error, 400 BadRequest)

/Server/ExecuteCloudScript PlayFabError(ServiceUnavailable, Unknown Error, 400 BadRequest)
0 Likes 0 ·
brendan avatar image brendan brandon@uprootstudios.com commented ·

Is this Unity 2018 or 2019? Unity's HTTP stack using TLS 1.2, which shouldn't have any issues. Can you send us the complete response packet you're getting? Also, can you try remoting into the machine and getting a network capture?

0 Likes 0 ·
brandon@uprootstudios.com avatar image brandon@uprootstudios.com brendan commented ·

@Brendan Unity 2019.1.1f1, PlayFab Unity SDK 2.66.190509, using Unity Web Request as the Request Type.

I have a wireshark log from one of the containers in the Thunderhead VM which was started a few seconds before the calls were made and ends soon after, although the log is quite long. How should I send it to you?

0 Likes 0 ·
Show more comments
ravarna avatar image
ravarna answered

@Brandon Phillips, I am guessing you made the postman call from the same vM where the calls are failing from within the game server. Regarding the errors, do they error out immediately or do they actually take some time (potential internal timeout). I am just trying to see if we have seen similar experiences from other customers

10 |1200

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

brandon@uprootstudios.com avatar image
brandon@uprootstudios.com answered

@ravarna You are correct, it is while remoted into the VM where the calls fail. The calls fail immediately and not after a period of time, so my guess is that it isn’t a network issue.

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.