Geofencing
When a user joins a channel, Signaling SDK automatically connects them to the closest geographical region of Agora SD-RTN™. However, to meet the laws and regulations of your region, you may want to filter in or filter out connections to a specific geographical region. Agora geofencing enables you to control and customize data routing in your app by specifying the Agora SD-RTN™ region users connect to.
Understand the tech
This section shows you how to enable geofencing in your app. The following figure shows the workflow you implement for geofencing:
Prerequisites
In order to follow this procedure you must have:
- Set up the Signaling SDK reference app.
Implement geofencing in your app
This section shows how to use the Signaling SDK to implement geofencing in your app.
Set the geofencing configuration
Test geofencing
To test the geofencing functionality:
-
Configure the project
-
Open the file
<samples-root>/signaling-manager/src/main/res/raw/config.json
-
Set
appId
to the AppID of your project. -
Choose one of the following authentication methods:
- Temporary token:
- Generate an RTM token using your
uid
. - Set
token
to this value inconfig.json
.
- Generate an RTM token using your
- Authentication server:
- Setup an Authentication server
- In
config.json
, set:token
to an empty string.serverUrl
to the base URL for your token server. For example:https://agora-token-service-production-yay.up.railway.app
.
- Temporary token:
-
-
Run the reference app
- In Android Studio, connect a physical Android device to your development machine.
- Click Run to start the app.
- A moment later you see the project installed on your device.
-
Test geofencing
Login to Signaling as multiple users, then send and receive messages using geofencing.
If your app fails to connect to the specified region of Agora SD-RTN™, instead of connection to another Agora SD-RTN™ region, Signaling SDK throws an error. If a firewall is deployed in your network environment, ensure that you:
- Whitelist certain domains
- Allow all IP addresses
- Open the firewall ports defined in IP addresses for Cloud Proxy.
Reference
This section contains information that completes the information in this page, or points you to documentation that explains other aspects to this product.
Firewall requirements
If a firewall is deployed in your network environment, ensure that you add the domains in the following table according to the region you specify, allow all IP addresses, and open the following firewall ports.
-
Whitelist domains
Region Domain Mainland China
webrtc2-ap-web-2.agoraio.cn
webrtc2-ap-web-4.agoraio.cn
statscollector-3.agoraio.cn
statscollector-4.agoraio.cn
logservice-china.agora.io
North America
ap-web-1-north-america.agora.io
ap-web-2-north-america.agora.io
statscollector-1-north-america.agora.io
statscollector-2-north-america.agora.io
logservice-north-america.agora.io
Europe
ap-web-1-europe.agora.io
ap-web-2-europe.agora.io
statscollector-1-europe.agora.io
statscollector-2-europe.agora.io
logservice-europe.agora.io
Japan
ap-web-1-japan.agora.io
ap-web-2-japan.agora.io
statscollector-1-japan.agora.io
statscollector-2-japan.agora.io
logservice-japan.agora.io
India
ap-web-1-india.agora.io
ap-web-2-india.agora.io
statscollector-1-india.agora.io
statscollector-2-india.agora.io
logservice-india.agora.io
Asia excluding mainland China
ap-web-1-asia.agora.io
ap-web-2-asia.agora.io
statscollector-1-asia.agora.io
statscollector-2-asia.agora.io
logservice-asia.agora.io
-
Port - See the Firewall Requirements