question

Ferry Halim avatar image
Ferry Halim asked

GetPlayersInSegment failed hourly,GetPlayersInSegment failed once every hour

I have a scheduled task running every 10 minute. The task run a Cloudscript

GetPlayersInSegment function. The task would run successfully for 5 times, and failed 1 time. This pattern repeats hourly.

What caused this task to fail every hour?

Title ID 5477D

Task ID 63C30780F25F77E3

,

I have a scheduled task running every 10 minute. The task run a Cloudscript

GetPlayersInSegment function. The task would run successfully for 5 times, and failed 1 time. This pattern repeats hourly.

What caused this task to fail every hour?

Title ID 5477D

Task ID 63C30780F25F77E3

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.

Ivan Cai avatar image Ivan Cai ♦ commented ·

Can you provide the segment and task configuration and cloudscript function code to reproduce?

0 Likes 0 ·
Ferry Halim avatar image Ferry Halim Ivan Cai ♦ commented ·

Task config:

0 Likes 0 ·
segment.jpg (29.6 KiB)
task.jpg (47.3 KiB)
Ivan Cai avatar image Ivan Cai ♦ Ferry Halim commented ·

I can reproduce your issue on my side. Do you have access to support tickets? If so, please create one so that one of our engineers can work closely with you regarding this issue.

0 Likes 0 ·
Ferry Halim avatar image Ferry Halim Ivan Cai ♦ commented ·
// renew 'samplevillages' array by getting players in 'villages' segment
handlers.renewsamplevillages = function () {
    var result = server.GetPlayersInSegment({"SegmentId":"157202E64DB6EAD", "MaxBatchSize":50, "SecondsToLive":60});
    var profiles = result.PlayerProfiles;
    if (profiles) {
        var arr = [];
        // get necessary data from the profiles
        for (let i = 0; i < profiles.length; i++) {
            var a = profiles[i];
            arr.push({"ID":a.PlayerId,"gr":a.Statistics.Village_groundarea})
        }
        // put the result in title internal data
        setinternaldata('samplevillages',JSON.stringify(arr));
    }
};

function setinternaldata(key,value) {
    var result = server.SetTitleInternalData({"Key":key, "Value":value});
    return result;
}
0 Likes 0 ·
Ferry Halim avatar image Ferry Halim commented ·

Unfortunately I don't have access to support ticket.

0 Likes 0 ·

1 Answer

·
Ivan Cai avatar image
Ivan Cai answered

There seems to be latency spikes for the "GameServer/GetPlayersInSegment" API that happen nearly every hour, on the hour. You can try to offset the start time of the task. For instance, have the task run every 10 minutes, but have it start either five minutes before the hour or five minutes after the hour. I think that this CRON expression would work "5,15,25,35,45,55 * * * *". That would run the task every ten minutes, starting 5 minutes after the hour.

1 comment
10 |1200

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

franklinchen avatar image franklinchen commented ·

In additional to Ivan's suggestion, there is another potential solution to this problem. Instead of having you run a job every ten minutes that queries the segment in question, you can instead setup CloudScript to be invoked automatically each time that a player enters or leaves a segment. Instructions for that can be found here: https://docs.microsoft.com/en-us/gaming/playfab/features/data/playerdata/player-segment-configuration

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.