Regions
Photon Cloud provides you with global connectivity to allow low latency gaming all around the world.
The initial connection of clients goes to a Photon Name Server, which provides the list of available regions.
Each region is completely separate from the others and consists of a Master Server (for matchmaking) and Game Servers (hosting rooms).
The full list of available regions is below. In the Dashboard, you can define which regions should be available for the clients.
Contents
Setup Regions In PUN
ConnectToBestCloudServer(string gameVersion)
connects your client to the Master Server with the lowest ping.
Results from pinging all Photon Cloud Master servers are saved in PlayerPrefs.
Use OverrideBestCloudServer(CloudRegionCode region)
to explicitly set another region as "best" one.
You can set up the region as part of editing the PhotonServerSettings asset.
Connecting to a region then becomes as easy as calling PhotonNetwork.ConnectUsingSettings()
.
For additional setup info using PUN refer to the Initial Setup doc.
Best Region Considerations
"Best Region" option is not deterministic. Sometimes it may be "random" due to little variations or exact same ping calculations.
Theoretically, you could:
- have the same exact ping to multiple regions from the same device. So its random, if you end up with different regions on clients connected to the same network.
- different ping values for the same region on different devices (or different retries on the same device) connected to the same network.
For instance, in the case of "us" and "usw" (or "ru" and "rue"), you could either make use of the online regions whitelist to select the ones you want and drop the others or connect to an explicit region.
Available Regions
Photon Cloud has servers in several regions, distributed across multiple hosting centers over the world.
Each Photon Cloud region is identified by a "region token".
To pass the region token with the "Connect" method of your client, call PhotonNetwork.ConnectToRegionMaster(regionCode, gameVersion)
.
List of available regions and tokens:
Region | Hosted in | Token |
---|---|---|
Asia | Singapore | asia |
Australia | Melbourne | au |
Canada, East | Montreal | cae |
Chinese Mainland1 (See Instructions) | Shanghai | cn |
Europe | Amsterdam | eu |
India | Chennai | in |
Japan | Tokyo | jp |
Russia | Moscow | ru |
Russia, East | Khabarovsk | rue |
South Africa | Johannesburg | za |
South America | Sao Paulo | sa |
South Korea | Seoul | kr |
USA, East | Washington D.C. | us |
USA, West | San José | usw |
1: Chinese Mainland region needs separate AppId and subscription.
Dashboard Regions Filtering
You can filter the list of available Photon Cloud regions per application on the fly directly from the dashboard.
Go to the dashboard and then click "Manage" for a chosen application and then click "Edit". You will find an input field where you can enter the list of whitelisted regions as follows:
- the allowed list should be a string of region tokens separated by semicolons. e.g. "eu;us".
- region tokens are case insensitive and are defined here.
- undefined or unrecognized region tokens will be ignored from the list.
- empty ("") or malformed string (e.g. ";;;") means empty list.
- empty list means all available regions are allowed.
Once you confirm and save, the operation GetRegions
will return only the filtered list of regions.
Thus, clients should select from that list but it's fully possible clients connect to any available region explicitly.
Take into consideration that dashboard updates propagation can take up to 10 minutes.
Using The Chinese Mainland Region
The Photon Name Server has to be local to China, as the firewall might block the traffic otherwise. The Chinese Photon Name Server is "ns.photonengine.cn".
Connecting with clients from outside of China mainland will most likely not produce good results. Also, connecting from the Photon servers to servers outside of China mainland (e.g. for Custom Authentication, WebHooks, WebRPCs) might not be reliable.
Also, for legal reasons, you need a separate build for China and we recommend using a separate AppId with it. For example, use a compile condition (of your choice) to change the AppId and the Photon Name Server depending on the build.
Follow the instructions corresponding to your client SDK to make a special build for the Chinese market.
- Set the AppId to the application that has China region unlocked.
If you want to use the same project and have different builds you can do something like this:
void Awake() { // TODO: replace compile condition with your own #if CHINA PhotonNetwork.PhotonServerSettings.AppID = "ChinaPUNAppId"; // TODO: replace with your own AppId #else PhotonNetwork.PhotonServerSettings.AppID = "nonChinaPUNAppId"; // TODO: replace with your own AppId #endif }
- Open the "NetworkingPeer.cs" file and set the
NameServerHost
to "ns.photonengine.cn": - Update
CloudRegionCode
andCloudRegionFlag
enums to add new "CN" (or "cn") region token as follows: - Use
PhotonNetwork.ConnectToRegion(CloudRegionCode.cn, gameVersion)
to connect to Chinese Mainland region.