A class defining the properties of the config parameter in the createClient method.

Note

Ensure that you set mode and codec.

example

Sample code

var config = {
     mode: "live",
     codec: "vp8",
     proxyServer: "YOUR HTTP PROXY SERVER IP",
     turnServer: {
         turnServerURL: "YOUR TURNSERVER URL",
         username: "YOUR USERNAME",
         password: "YOUR PASSWORD",
         udpport: "THE UDP PORT YOU WANT TO ADD",
         tcpport: "THE TCP PORT YOU WANT TO ADD",
         forceturn: false
     }
}
var client = AgoraRTC.createClient(config);

Hierarchy

  • ClientConfig

Index

Properties

Optional areaCode

areaCode: AREAS[]

The region for connection.

Since
   3.1.2

This advanced feature applies to scenarios that have regional restrictions.

By default, the SDK connects to nearby Agora servers. After specifying the region, the SDK connects to the Agora servers within that region. For details, see AREAS.

Note:

  • The regional restriction is a global configuration and applies to the entire browser tab. If one Client specifies the connection region, all the other Clients created on the same tab follow the restriction.
  • The SDK supports specifying only one region.

Sample code

var config = {
    mode: "live",
    codec: "vp8",
    // Specify the region as North America.
    areaCode: [AgoraRTC.AREAS.NORTH_AMERICA]
};
var client = AgoraRTC.createClient(config);

codec

codec: "vp8" | "h264"

The codec the Web browser uses for encoding.

  • "vp8": Sets the browser to use VP8 for encoding.
  • "h264": Sets the browser to use H.264 for encoding.

Note

mode

mode: "live" | "rtc"

The channel profile.

Agora Web SDK needs to know the application scenario to apply different optimization methods.

Currently Agora Web SDK supports the following channel profiles:

  • "live": Sets the channel profile as live broadcast. Host and audience roles that can be set by calling the Client.setClientRole method. The host sends and receives voice/video, while the audience can only receive voice/video.
  • "rtc": Sets the channel profile as communication. This is used in one-on-one calls or group calls, where all users in the channel can talk freely.

Note

If you need to communicate with Agora Native SDK, Agora recommends the following settings:

  • For Native SDK v2.3.2 and later:
    • Set mode as "rtc" or "live" if the Native SDK uses the communication channel profile.
    • Set mode as "live" if the Native SDK uses the live broadcast channel profile.
  • For Native SDK before v2.3.2, set mode as "live" regardless of which channel profile the Native SDK uses.

Note

The "rtc" mode supports the Agora Recording SDK 2.3.3 or later.

Optional proxyServer

proxyServer: string

Your HTTP proxy server domain name.

You can also use cloud proxy by startProxyServer. See Use Cloud Proxy for details.

ASCII characters only, and the string length must be greater than 0 and less than 256 bytes.

Note

  • We support https/SSL proxy server via port 443.
  • Ensure that the proxy server supports wss (WebSocket Secure).
  • For the required firewall ports, see Firewall Requirements.

Optional turnServer

turnServer: TurnServer[]

TURN server configurations.

An array of the TurnServer objects. You can pass configurations of multiple TURN servers to this property.

You can also use cloud proxy by startProxyServer. See Use Cloud Proxy for details.