To meet the laws and regulations of different countries or regions, the Agora RTC SDK supports geofencing. After enabling geofencing, the SDK only connects to Agora servers within the specified region, regardless of where your app users are located.
For example, if you specify North America as the region for connection, when two users attempt to connect to Agora servers from different locations, the result is as follows:
Specified region for connection | App user location | Actual region for connection | User experience after connection 1 |
---|---|---|---|
North America | North America | North America | Normal |
China | Can be less than optimal 2 |
By default, the SDK connects to nearby Agora servers. To use the geofencing feature, call AgoraRTC.setArea
to specify the region for connection, so that the SDK only connects to the Agora servers within that region.
You can specify the region for connection in either of the following ways:
areaCode
parameter. The region for connection is the same as the value you set.areaCode
parameter as "GLOBAL"
, and set the excludedArea
parameter to another value. The region for connection is all of the remaining areaCode
values combined.Supported values of areaCode
include:
ASIA
: Asia, excluding Mainland ChinaCHINA
: ChinaEUROPE
: EuropeGLOBAL
: GlobalINDIA
: IndiaJAPAN
: JapanNORTH_AMERICA
: North AmericaSpecify the region for connection as North America:
AgoraRTC.setArea({
areaCode:"NORTH_AMERICA"
})
Exclude Mainland China from the regions for connection:
AgoraRTC.setArea({
areaCode:"GLOBAL",
excludedArea:"CHINA"
})
Specify the regions for connection as North America, Europe, Asia, and India. You can use either of the following code snippets:
AgoraRTC.setArea({
areaCode:["NORTH_AMERICA","EUROPE","ASIA","INDIA"]
})
AgoraRTC.setArea(["NORTH_AMERICA","EUROPE","ASIA","INDIA"])
If a firewall is deployed in your network environment, ensure that you whitelist certain domains, allow all IP addresses, and open certain firewall ports according to Firewall Requirements.