Skip to main content

Connect through restricted networks with Cloud Proxy

You use Agora Cloud Proxy 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, Cloud Proxy offers a HTTP proxy service. The following figure shows the Cloud Proxy workflow:

cloud proxy

The steps you need to implement in your app are:

  1. Before connecting to Agora SD-RTN™, set Signaling SDK to request a connection to Cloud Proxy.

  2. When the request succeeds, Cloud Proxy sends back the proxy information.

  3. Signaling SDK sends signaling and media data to Cloud Proxy, which forwards this data to Agora SD-RTN™.

  4. Agora SD-RTN™ sends signaling and media data to Cloud Proxy, which forwards it to Signaling SDK.

Prerequisites

To follow this page, you must:

Implement communication using Cloud Proxy

This section shows how to use the Signaling SDK to implement Cloud Proxy in your app, step-by-step.

  1. Set Signaling SDK to connect to Cloud Proxy before you join a channel

    To access Agora SD-RTN™ in a restricted network environment, call setCloudProxy and pass 0 as a parameter to select the automatic mode for transmission. The setCloudProxy method returns 0 upon successful initiation of cloud proxy service.

    To enable the Cloud Proxy service in your app, in /app/java/com.example.<projectname>/MainActivity, add the following code after agoraEngine = RtcEngine.create(config);:


    _7
    // Start cloud proxy service and set automatic transmission mode.
    _7
    int proxyStatus = agoraEngine.setCloudProxy(0);
    _7
    if (proxyStatus == 0) {
    _7
    showMessage("Proxy service started successfully");
    _7
    } else {
    _7
    showMessage("Proxy service failed with error :" + proxyStatus);
    _7
    }

Test Cloud Proxy

To test this functionality:

  1. Set the APP ID

    In agora-manager/res/raw/config.json, set appId to the AppID of your project.

  2. Set the authentication method

    Choose one of the following authentication methods:

    • Temporary token:
      1. Set rtcToken with the value of your temporary token.
      2. Set channelName - with the name of a channel you used to create the token.
    • Authentication server:
      1. Setup an Authentication server
      2. In config.json, set:
        • channelName with the name of a channel you want to join.
        • rtcToken to an empty string.
        • serverUrl to the base URL of your authentication server. For example, https://agora-token-service-production-1234.up.railway.app.
  3. Start the Android reference app

    1. In Android Studio, connect a physical Android device to your development machine.

    2. Click Run to start the app.

      A moment later you see the project installed on your device. If this is the first time you run the project, you need to grant microphone and camera access to your app.

  1. In Android Studio, open app/java/com.example.<projectname>/MainActivity, and update appId, channelName and token with the values for your temporary token.

  2. Connect a physical Android device to your development device.

  3. In Android Studio, click Run app. A moment later you see the project installed on your device.

    If this is the first time you run the project, grant microphone and camera access to your app.

  1. Click Join to start a call.

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