question

Kim Strasser avatar image
Kim Strasser asked

How long does it take to make API calls?

How long does it normally take to make client API calls like PlayFabClientAPI.LoginWithIOSDeviceIDAsync, PlayFabClientAPI.GetUserDataAsync, PlayFabClientAPI.GetPlayerStatisticsAsync or PlayFabClientAPI.ExecuteCloudScriptAsync?

Is there a time limit for client API calls? Is it possible that a call fails when it takes too much time to make it?

I want to find out how long that it could take until the player gets his data from PlayFab. For example, the player makes several API calls when he clicks on the login button. I want to calculate how long that it could take until the player has received the data from PlayFab. Is it possible to calculate the maximum time?

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

·
Seth Du avatar image
Seth Du answered

The response time is not fixed, it depends on many factors. However, if you want to calculate the precise response time of a specific API call, one of the most convenient way is to use Postman(RESTful testing tools), where response time is stated above the response field:


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

Kim Strasser avatar image Kim Strasser commented ·

Is it possible that a specific API call could fail because it takes too long to execute it? Does PlayFab automatically cancel API calls that take too long to complete them?

Secondly, what happens if the player has a very bad/slow connection on his mobile phone? For example, the player calls PlayFabClientAPI.GetUserDataAsync when he still has a good connection, then the player loses his good connection and therefore he can not receive the result of the PlayFabClientAPI.GetUserDataAsync call. 1 minute later, the player has again a good connection on his mobile phone. What happens in this case with the result of the API call? Will the player receive his user data of this API call or does this call fail and the player will get a specific error message?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Kim Strasser commented ·

>>Is it possible that a specific API call could fail because it takes too long to execute it?

Yes, eventually it will return error if the waiting time is too long. There are no cancellation features from PlayFab because it can be achieved on your own in the client side.

>>what happens if the player has a very bad/slow connection on his mobile phone?

Basically the data retrieval API has the fewer effects than Update related APIs. When the network connection is bad, there is no guarantee on sending requests or receiving callback. Refer to your scenario, you may just pause the game and wait for the correct callback response. Meanwhile, after few times failed attempts, the client may quit the game to the login page.

In terms of updates, it depends on whether the request has been sent. Player Data (aka. user data in GetUserData) has a property named DataVersion, which can be tracked to ensure the Player Data has been updated properly.

0 Likes 0 ·
Kim Strasser avatar image Kim Strasser Seth Du ♦ commented ·

Is it possible to cancel a client API call in the client code after it has been made?

For example, is it possible to cancel this API call in the client code after var result = await PlayFabClientAPI.GetUserDataAsync(new PlayFab.ClientModels.GetUserDataRequest() has been executed?

private async Task GetPlayerCountryData()
{
    var result = await PlayFabClientAPI.GetUserDataAsync(new PlayFab.ClientModels.GetUserDataRequest()
    {
        PlayFabId = PlayerPlayFabID,
        Keys = null
    });


    // Cancelling here?


    if (result.Error != null)
        Console.WriteLine(result.Error.GenerateErrorReport());
    else
    {
        if (result.Result.Data == null || !result.Result.Data.ContainsKey("Country") || !result.Result.Data.ContainsKey("City"))
            Console.WriteLine("No Country/City");
        else
        {
            Console.WriteLine("Country: " + result.Result.Data["Country"].Value);
            Console.WriteLine("City: " + result.Result.Data["City"].Value);
        }
    }
}
0 Likes 0 ·

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.