Client configuration

Updated

Configure connection protocol, proxy, and log settings.

Client configuration enables you to customize the behavior of your Signaling client instance according to your app's requirements.

Understand the tech

When initializing a Signaling client instance, configure any or all of the following features:

  • Geographical area access When a user joins a channel, Signaling SDK automatically connects them to the closest geographical region of Agora SDRTN®. However, to comply with local laws and regulations, you may want to specify or restrict connections to a specific geographical area. Agora enables you to control and customize data routing in your app by specifying the Agora SDRTN® region users connect to.

  • Enable proxy connection You use a proxy connection to ensure reliable connectivity for your users when they connect from an environment with a restricted network. This helps in maintaining a stable connection even in environments with network restrictions.

  • Private deployment Private deployment enables you to deploy and manage the Signaling environment on your own infrastructure rather than using Agora services. This feature is fully supported since version 2.2.0.

  • Logging Logging enables you to output detailed information from the SDK for locating and fixing problems during the development and testing phases. By configuring logging settings, you can control the amount and type of information logged by the SDK.

  • Data encryption Enabling encryption ensures that only authorized users are able to read messages sent through Signaling. Signaling provides built-in encryption methods that guarantee data confidentiality during transmission. For implementation details, see Data encryption.

Prerequisites

Ensure that you have integrated the Signaling SDK in your project and implemented the framework functionality from the SDK quickstart page.

Configure the client instance

This section explains how to set up and customize various features when you initialize a Signaling client instance.

Geographical area configuration

To specify a geographical area for Agora SDRTN® connections, refer to the following code:

// Set whitelist and blacklist areas
AgoraRTM.setArea({ areaCodes: ["GLOBAL"], excludedArea: "CHINA" })

Proxy configuration

In some environments with restricted network services, you may need to set up a proxy service to access external resources. Signaling supports configuring a proxy service. You enable this feature during the Signaling instance initialization.

const { RTM } = AgoraRTM;
const appId = "your_appId";
const userId = "your_userId";
const rtmConfig = { cloudProxy: true };
const rtm = new RTM(appId, userId, rtmConfig);

This feature is only available for Message channels and User channels.

Private deployment configuration

Agora is committed to offering its customers flexible, secure, and customizable solutions. Since version 2.2.0, Signaling supports private deployments. This feature enables you to deploy and manage the Signaling environment yourself, giving you more control over your data and systems.

Signaling provides MESSAGE and STREAM services. Choose one or both services based on your needs and budget. The following code shows you how to configure a private environment that deploys both services simultaneously:

const appId = "your_appId";
const userId = "your_userId";
const rtmConfig = {
    privateConfig: {
        serviceType: ["MESSAGE", "STREAM"], // Service type for private deployment
        accessPointHosts: ["private.mynet.com"], // Private deployment server list, only domain name is supported
        domainMode: 2,
    }
};
const rtm = new RTM(appId, userId, rtmConfig);

Note

To upgrade the privately deployed Signaling Web SDK to v2.2.4 or later, set domainMode to 2 for compatibility. If you omit this parameter or use the default value 1, the SDK may fail to connect to the Signaling server.

To deploy a private environment, you need to set up the backend service. For assistance, please contact technical support.

Log configuration

In the development and testing phase of your app, you may need to output more detailed information to locate and fix problems. Enable log output of the SDK and set the log information level by configuring logLevel when initializing the Signaling client instance. You can view the log information in the browser console.

const { RTM } = AgoraRTM;
const appId = "your_appId";
const userId = "your_userId";
const rtmConfig = { logLevel : "debug" };
const rtm = new RTM(appId, userId, rtmConfig);

Choose the log level from the following:

Enumeration ValueDescription
debugOutput all logs.
infoOutput logs of level error, warn, and info.
warnOutput logs of level error, and warn.
errorOutput logs of level error.
noneNo log output.

When your app is released to production, set the log level to info.

Reference

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

For firewall configuration, see firewall requirements