Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • Bugs /
avatar image
Question by kfboelterbotl · Nov 22, 2017 at 09:36 PM · apisCloudScript

CloudScript Handler to get player IDs from segment often returns Internal Server Error

We have this CloudScript to get all the PlayFab Ids from player in a segment:

handlers.onGetOnlinePlayers = function(args, context)
{
  var onlineList = {};
  
  onlineList = server.GetPlayersInSegment({
    "SegmentId": "DF433C53264DE4EF"
  })
  
  var playerListIDs = {"onlinePlayers":[]};
  
  for(i =0; i < onlineList.ProfilesInSegment; i++)
  {
      playerListIDs.onlinePlayers.push(onlineList.PlayerProfiles[i].PlayerId);
  }
  
  return playerListIDs;
  
};

It works exactly how it should sometimes and finds all the players in the segment, however, this message is often received when executing it from the dashboard

{
    "FunctionResult": null,
    "Logs": [
        {
            "Level": "Error",
            "Message": "PlayFab API request failure",
            "Data": [
                [
                    []
                ],
                [
                    [
                        [
                            []
                        ]
                    ]
                ],
                [
                    []
                ]
            ]
        }
    ],
    "ExecutionTimeSeconds": 7.0001722,
    "MemoryConsumedBytes": 108888,
    "APIRequestsIssued": 1,
    "HttpRequestsIssued": 0,
    "Error": {
        "Error": "InternalServerError",
        "Message": "InternalServerError",
        "StackTrace": "Error\n    at handlers.onGetOnlinePlayers (9BBE-main.js:416:23)"
    }
}
Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Brendan · Nov 22, 2017 at 09:44 PM

Can we start with a high level overview of what you're attempting to accomplish? It looks like you're attempting to track on all online players. If so, that's not going to work for a few reasons:

1. Segment evaluation, which is an expensive operation, occurs on a call to GetPlayersInSegment. For that reason, you can't call it at high frequency, and certainly not based on a client-driven action.

2. Since we don't use a socket-based connection (we will provide this in a future release), you'd be tracking on this by updating some value on the player account. That's fine if you're doing it every minute or two, but if you're attempting to do this at high frequency, that runs the risk of exceeding our fair use terms.

3. For any game with a good user population, you'll exceed the limit on how many profiles can be returned in a single call to GetPlayersInSegment. Using the ContinuationToken in a Cloud Script isn't really an option because it would push the script to excessive API calls and processing time.

We will be providing a "presence" system of our own in a future release. For now, I would recommend using the player last login time (which you can get from the profile information in leaderboards, for example) as a way to get information on active players. Alternately, if your game is realtime gameplay focused, you may need to consider using a custom game server, so that you can have players connect to it for shared realtime information on others playing.

Comment
kfboelterbotl

People who like this

1 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    1 Person is following this question.

    avatar image

    Related Questions

    GetPlayerCombinedInfoRequest no longer includes DisplayName in response 2 Answers

    TypeError when trying to declare a call to server.GetPlayersInSegment(); 1 Answer

    Request timeout 3 Answers

    JSON Field Reformatting on Automation Save 2 Answers

    Get players in segment count Via cloud script and update title data 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges