Restrict media zones
Updated
Restrict access to Agora servers in the specified region
To meet the laws and regulations of different countries or regions, the Agora Video 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 |
|---|---|---|---|
| North America | North America | North America | Normal |
| North America | China | North America | There may be a significant impact on user experience. Due to the cross-region public Internet between the designated area and the area where the app user is located, poor quality of the public Internet network affects the audio and video experience. If the servers in the specified area are not available, the SDK reports an error directly. |
Restricted media zones is an advanced feature of the SDK. Use it only when required for use-cases with access security restrictions.
Implementation
When you specify an access area, audio, video and message data is not accessed from servers outside the specified area.
To specify the access area, set the AreaCode parameter in AgoraServiceConfig when calling the initialize method to initialize the agoraservice package. The following area codes are available:
AreaCodeGlob: Global (Default)AreaCodeCN: Mainland ChinaAreaCodeNA: North AmericaAreaCodeEU: EuropeAreaCodeAS: Asia, excluding mainland ChinaAreaCodeJP: JapanAreaCodeIN: India
Area codes support bitwise operations.
Refer to the following sample code to specify an access area:
svcCfg := agoraservice.NewAgoraServiceConfig()
svcCfg.AppId = appid
// Specify access to North American servers only
svcCfg.AreaCode = agoraservice.AreaCodeNA
// Initialize the `agoraservice` package
agoraservice.Initialize(svcCfg)