Skip to main content

You are viewing Agora Docs forBeta products and features. Switch to Docs


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:

Network Geofencing


In order to follow this procedure you must have:

Implement geofencing in your app

This section shows how to use the Signaling SDK to implement geofencing in your app.

Set the geofencing configuration

// Define the set of area codes
val areaCodes = EnumSet.of(RtmAreaCode.NA, RtmAreaCode.EU)

Apply the configuration to the Signaling Engine

try {
val rtmConfig = RtmConfig.Builder(appId, uid.toString())
.areaCode(areaCodes) // Specify the area codes
signalingEngine = RtmClient.create(rtmConfig)
localUid = uid
} catch (e: Exception) {
return false

Test geofencing

To test the geofencing functionality:

  1. Configure the project

    1. Open the file <samples-root>/signaling-manager/src/main/res/raw/config.json

    2. Set appId to the AppID of your project.

    3. Choose one of the following authentication methods:

      • Temporary token:
        1. Generate an RTM token using your uid.
        2. Set token to this value in config.json.
      • Authentication server:
        1. Setup an Authentication server
        2. In config.json, set:
          • token to an empty string.
          • serverUrl to the base URL for your token server. For example:
  2. Run the reference app

    1. In Android Studio, connect a physical Android device to your development machine.
    2. Click Run to start the app.
    3. A moment later you see the project installed on your device.
  3. 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:


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

    North America




    Asia excluding mainland China

  • Port - See the Firewall Requirements

API reference