Skip to main content

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

Connect through restricted networks

You use a proxy connection to ensure reliable connectivity for your users when they connect from an environment with a restricted network.

Understand the tech

To accommodate your end users’ firewall settings and business needs, Signaling SDK enables you to connect using a TCP proxy server.

The steps you need to implement in your app are:

  1. Set proxy configuration

  2. Apply the configuration to the Signaling Engine

Prerequisites

To follow this page, you must:

Implement communication using a TCP proxy

This section shows how to connect to Signaling using a third-party TCP proxy server.

Set proxy configuration


_7
// Define proxy configuration
_7
val proxyConfig = RtmProxyConfig(RtmConstants.RtmProxyType.HTTP,
_7
"<your proxy server domain name or IP address>",
_7
8080, // Your proxy server listening port,
_7
"<proxy login account>", // Optional
_7
"<proxy login password>" // Optional
_7
)

Apply the configuration to the Signaling Engine


_13
try {
_13
val rtmConfig = RtmConfig.Builder(appId, uid.toString())
_13
.presenceTimeout(config!!.optString("presenceTimeout").toInt())
_13
.useStringUserId(false)
_13
.eventListener(eventListener)
_13
.proxyConfig(proxyConfig) // Set proxy configuration
_13
.build()
_13
signalingEngine = RtmClient.create(rtmConfig)
_13
localUid = uid
_13
} catch (e: Exception) {
_13
notify(e.toString())
_13
return false
_13
}

Test proxy connection

To test your proxy connection:

  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: https://agora-token-service-production-yay.up.railway.app.
  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 proxy connection:

    1. Open a new instance of the reference app.
    2. Choose the Connect through restricted networks example.
    3. Log in to Signaling.
    4. Subscribe to a channel.
      You see your app starts the proxy service and magically connects to the Agora SD-RTN™ which was not possible in a restricted network environment.

Reference

This section contains information that completes the information in this page, or points you to documentation that explains other aspects to this product.

Signaling