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. As of v3.1.2, the Agora RTC Web SDK supports geofencing. You can specify the region for connection when creating a client instance by calling createClient
. Choose either of the following ways to specify the region for connection:
areaCode
parameter in ClientConfig
to specify only one 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
: Mainland ChinaEUROPE
: EuropeGLOBAL
: GlobalINDIA
: IndiaJAPAN
: JapanNORTH_AMERICA
: North Americavar config = {
mode: "live",
codec: "vp8",
// Specify the region for connection as North America
areaCode: [AgoraRTC.AREAS.NORTH_AMERICA]
};
var client = AgoraRTC.createClient(config);
var config = {
mode: "live",
codec: "vp8",
// // Exclude Mainland China from the regions for connection
areaCode: [AgoraRTC.AREAS.GLOBAL],
excludedArea: AgoraRTC.AREAS.CHINA
};
var client = AgoraRTC.createClient(config);
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.