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:
The steps you need to implement in your app are:
-
Before connecting to Agora SD-RTN™, set Signaling SDK to request a connection to Cloud Proxy.
-
When the request succeeds, Cloud Proxy sends back the proxy information.
-
Signaling SDK sends signaling and media data to Cloud Proxy, which forwards this data to Agora SD-RTN™.
-
Agora SD-RTN™ sends signaling and media data to Cloud Proxy, which forwards it to Signaling SDK.
Prerequisites
To follow this page, you must:
-
Setup the Signaling SDK reference app
-
Contact support@agora.io and enable Cloud Proxy for your project.
-
Configure your firewall to allow communication through the Cloud Proxy allowed IP address.
Implement communication using Cloud Proxy
This section shows how to use the Signaling SDK to implement Cloud Proxy in your app, step-by-step.
-
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 pass0
as a parameter to select the automatic mode for transmission. ThesetCloudProxy
method returns0
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 afteragoraEngine = RtcEngine.create(config);
:
Test Cloud Proxy
To test this functionality:
-
Set the APP ID
In
agora-manager/res/raw/config.json
, setappId
to the AppID of your project. -
Set the authentication method
Choose one of the following authentication methods:
- Temporary token:
- Set
rtcToken
with the value of your temporary token. - Set
channelName
- with the name of a channel you used to create the token.
- Set
- Authentication server:
- Setup an Authentication server
- 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
.
- Temporary token:
-
Start the Android 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. If this is the first time you run the project, you need to grant microphone and camera access to your app.
-
-
In Android Studio, open
app/java/com.example.<projectname>/MainActivity
, and updateappId
,channelName
andtoken
with the values for your temporary token. -
Connect a physical Android device to your development device.
-
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.
- 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.