To meet the laws and regulations of different countries or regions, the Agora RTC SDK supports geofencing. After enabling geofencing, the Agora SDK only connects to Agora servers within the specified region.
For example, if you specify North America as the region for connection, the SDK only connects to Agora servers in North America. When there is no available server in North American, the SDK throws an error instead of connecting to servers in another region.
By default, the SDK connects to nearby Agora servers. You can call AgoraRTC.setArea
to specify the region for connection. Choose either of the following ways to specify the region for connection:
areaCode
parameter to specify the region for connection.areaCode
parameter to specify a large region and the excludedArea
parameter to specify a small region. The region for connection is the large region excluding the small region. You can only specify the large region as "GLOBAL"
.After specifying the region, the SDK connects to the Agora servers within that region.
The supported 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.