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 /
  • API and SDK Questions /
avatar image
Question by Brian Jordan · Mar 28, 2018 at 05:06 PM · apisunity3dsdksMatchmaking

Region Ping measured RTT inaccurate/high using Unity HTTP, recommendations or ICMP ping protocol support?

We're hoping to provide users with a list of available regions and estimated pings to each region, and then use that list to prioritize region-focused matchmaking.

We're running in to a problem where:

  1. The available HTTP GET request tools within Unity (WWW, UnityWebRequest, BestHTTP.HTTPRequest) do not seem suitable for measuring RTT, as they all have overhead that makes ~23ms ping regions measure as ~200+ms (and causing mis-sorting of regions due to the inaccuracy).
  2. Unity's built-in Ping works via the ICMP ping protocol, and Region.PingUrls (and their host IPs) do not seem to support it?

Is there a recommended way to ping these URLs from within Unity, otherwise would it be possible to enable an inbound ICMP rule on the Region Ping URL hosts (e.g. for Windows server)?

EDIT: looks like one alternative may be to create a manual mapping of regions to analogous AWS dynamodb endpoints (like CloudPing does, e.g. http://dynamodb.us-east-1.amazonaws.com/), perform a DNS lookup (which may block execution?) and then ICMP ping those IPs (e.g. 52.94.3.30). Though that feels a bit brittle as it relies on those endpoints / their firewall configuration staying the same. (EDIT 2: This does seem to give realistic RTT values, see gist)

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 1807605288 · Mar 28, 2018 at 07:52 PM

HTTPS calls generally involve a bunch of authentication and back and forth validation before any of the actual request is transmitted. So, yes, I agree using a PlayFab api call to determine your ping time is probably not appropriate.

We don't provide any utility for determining ping times in our SDK, as you clearly discovered.

I think you're on the right track, though. You're already ahead of the StackOverflow answers I found. If you want to avoid blocking, you're going to have to create a thread, do the work in that other thread, and then send the results back to the unity main thread. At best this just means that your main thread is turning a spinner while the alternate thread does the work.

Otherwise, I think you understand the situation better than I do, since you've actually got some results that match your expectations. I share your concerns about those endpoints...
You might keep the mapping of region urls in your titledata. Start your game by loading titledata, getting the region to url mapping from titledata, such that if it changes, you can update it without generating another build.

I only have those minor tweaks for the solution you describe, and I think everything you're doing sounds right, and won't conflict with anything on our side.

Good luck.

Comment

People who like this

0 Show 2 · 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
avatar image Brian Jordan · Mar 28, 2018 at 08:19 PM 0
Share

Thanks Paul, & great tip on keeping the URLs in titledata (worst case if they stop responding I could quickly spin up some small ec2 instances in those regions).

Just to clarify one bit, the PlayFab API does already define a field PingUrl:

/// <summary>
/// url to ping to get roundtrip time
/// </summary>
public string PingUrl;

which gives an HTTP endpoint (in the form of: http://1.2.3.4/ping) in the given region, but that given IP/host does not respond to ping protocol requests.

It is also interesting how CloudPing.info manages to get reasonable looking latency results using in-browser GET requests (fake img tags to 404 endpoints, then record the time onerror) -- it may just be the timing of how Unity calls-back for its HTTP requests across frames that causes the inaccurate measurements.

avatar image Brendan ♦♦ Brian Jordan · Mar 28, 2018 at 10:32 PM 0
Share

That's the PingURL for your custom game servers - it's not part of the PlayFab core service.

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

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Unity Mirror and Playfab GameServers 1 Answer

    Experiments Treatment variables 1 Answer

    ​How can a client launch their game server via "Server 2.0" with custom settings? 1 Answer

    Getting a MatchID in Server 2 Answers

    What is the intended way to deserialize custom data from an api call.,Intended way to deserialize custom data from api call. 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