Can't get ping for all regions

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Can't get ping for all regions

Insthync
2020-09-14 05:21:55

I've override OnRegionListReceived from MonoBehaviourPunCallbacks class, I can get all regions but almost all of them wasn't pinged. Only the best region I've connected was pinged. Whats I can do to get all regions ping?

Comments

L3sc
2020-09-14 10:53:07

Can you try like this?

 public override void OnRegionListReceived(RegionHandler regionHandler)  
    {  
        regionHandler.PingMinimumOfRegions(PingCompleteCallback, "");  
    }

    void PingCompleteCallback(RegionHandler regionHandler)  
    {  
       //Ping result about to all regions  
        List<Photon.Realtime.Region> regions = regionHandler.EnabledRegions;  
        foreach (var region in regions)  
        {  
        	Debug.Log(region.Ping);  
        }

        //Region with lowest ping  
        Debug.Log(regionHandler.BestRegion.Code + " " + regionHandler.BestRegion.Ping);

       }  

This callback probably returning best ping result.

Insthync
2020-09-15 00:17:13

Yes, I've try it, as I said I was override OnRegionListReceived function but when get ping from regions each ping value is int.MaxValue except the best region.

Insthync
2020-09-18 07:14:00

I can fix ping problem by ServerSettings.ResetBestRegionCodeInPreferences() before connect to best cloud server.

About best cloud server connection, when connecting to best cloud server, it will connect to name server.
Then when connect to name server it will pinging all regions
If PUNCloudBestRegion not existed, if it's existed it will not ping all regions.

JohnTube
2020-09-18 09:39:37

Hi @Insthync,

Why do you need/want to ping ALL regions (every time)?
Maybe there is a misunderstanding of how best region works and how it's determined.
Read more here.

Insthync
2020-09-18 12:43:52

Players might want to play with other players from difference regions, and they may want to see other region's ping to decide to connect. It's does not have to ping everytime, just once when start a game is okay. Only way to get regions list is to connect to best cloud region, but when connect to best cloud region, only best cloud region is pingged maybe because it was stored in reference when ServerSettings.ResetBestRegionCodeInPreferences() it will re-ping all regions.

Back to top