# Client configuration (/en/realtime-media/rtm/build/connect-and-authenticate/client-configuration/react-native)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

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

    ## Understand the tech [#understand-the-tech-5]

    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.

    * **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](../secure-your-app-and-data/data-encryption).

    ## Prerequisites [#prerequisites-5]

    Ensure that you have integrated the Signaling SDK in your project and implemented the framework functionality from the [SDK quickstart](../../index) page.

    ## Configure the client instance [#configure-the-client-instance-5]

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

    ### Geographical area configuration [#geographical-area-configuration-3]

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

    ```tsx

    const client = createAgoraRtmClient(
     new RtmConfig({
       userId: 'your_userId',
       appId: 'your_appId',
       useStringUserId: true,
       areaCode: RtmAreaCode.as | RtmAreaCode.cn, // Multiple areas using bitwise OR
       // Or use a single area:
       // areaCode: RtmAreaCode.as,
     })
    );
    ```

    Available area codes:

    | Area Code          | Description                   |
    | ------------------ | ----------------------------- |
    | `RtmAreaCode.na`   | North America                 |
    | `RtmAreaCode.eu`   | Europe                        |
    | `RtmAreaCode.as`   | Asia excluding Mainland China |
    | `RtmAreaCode.jp`   | Japan                         |
    | `RtmAreaCode.in`   | India                         |
    | `RtmAreaCode.cn`   | Mainland China                |
    | `RtmAreaCode.glob` | Global (default)              |

    ### Connection protocol [#connection-protocol-2]

    To ensure connection stability and continuous service availability, the RTM client establishes two transmission links for each service (`MESSAGE` service and `STREAM` service) when connecting to the edge server. By default, these links use the TCP and UDP protocols, respectively. This design ensures that network issues on one link do not affect the overall transmission.

    In some cases, users may find that their network does not support UDP port transmission. To ensure the dual-link design operates effectively, the SDK allows users to configure both links to use the TCP protocol by setting the `protocolType` field in the `RtmConfig`:

    ```tsx

    const client = createAgoraRtmClient(
     new RtmConfig({
       userId: 'your_userId',
       appId: 'your_appId',
       useStringUserId: true,
       protocolType: RtmProtocolType.tcpOnly, // Use TCP only for both links
     })
    );
    ```

    Available protocol types:

    | Protocol Type             | Description                    |
    | ------------------------- | ------------------------------ |
    | `RtmProtocolType.tcpUdp`  | Use both TCP and UDP (default) |
    | `RtmProtocolType.tcpOnly` | Use TCP only for both links    |

    <CalloutContainer type="info">
      <CalloutTitle>
        Info
      </CalloutTitle>

      <CalloutDescription>
        The SDK does not support configuring both links to use the UDP protocol simultaneously.
      </CalloutDescription>
    </CalloutContainer>

    ### Presence timeout configuration [#presence-timeout-configuration]

    Configure the presence timeout to control how long the server waits before considering a client offline:

    ```tsx

    const client = createAgoraRtmClient(
     new RtmConfig({
       userId: 'your_userId',
       appId: 'your_appId',
       useStringUserId: true,
       presenceTimeout: 60, // Timeout in seconds (5-300 range)
     })
    );
    ```

    ### User ID type configuration [#user-id-type-configuration]

    Configure whether to use string or numeric user IDs:

    ```tsx

    // Using string user IDs (recommended)
    const clientString = createAgoraRtmClient(
     new RtmConfig({
       userId: 'user123',
       appId: 'your_appId',
       useStringUserId: true, // Use string user IDs
     })
    );

    // Using numeric user IDs
    const clientNumeric = createAgoraRtmClient(
     new RtmConfig({
       userId: '1234567', // Must be numeric string when useStringUserId is false
       appId: 'your_appId',
       useStringUserId: false, // Use numeric user IDs
     })
    );
    ```

    <CalloutContainer type="info">
      <CalloutDescription>
        When using both Agora RTC and RTM, ensure the `userId` type is consistent across both SDKs.
      </CalloutDescription>
    </CalloutContainer>

    ### Log configuration [#log-configuration-3]

    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 `RtmLogConfig` when initializing the Signaling client instance:

    ```tsx

    const logConfig = {
     filePath: './logfile/', // Log file path
     fileSizeInKB: 512, // Log file size in KB (128-1024 range)
     level: RtmLogLevel.info, // Log report level
    };

    const client = createAgoraRtmClient(
     new RtmConfig({
       userId: 'your_userId',
       appId: 'your_appId',
       useStringUserId: true,
       logConfig: logConfig, // Set log configuration
     })
    );
    ```

    Choose the log level from the following:

    | Enumeration value   | Description                                                                                                                 |
    | ------------------- | --------------------------------------------------------------------------------------------------------------------------- |
    | `RtmLogLevel.none`  | `0x0000`: Do not output any logs.                                                                                           |
    | `RtmLogLevel.info`  | `0x0001`: Output logs of levels `FATAL`, `ERROR`, `WARN`, and `INFO`. Best practice is to set the log level to this option. |
    | `RtmLogLevel.warn`  | `0x0002`: Only output logs of levels `FATAL`, `ERROR`, and `WARN`.                                                          |
    | `RtmLogLevel.error` | `0x0004`: Only output logs of levels `FATAL` and `ERROR`.                                                                   |
    | `RtmLogLevel.fatal` | `0x0008`: Only output logs at the `FATAL` level.                                                                            |

    <CalloutContainer type="info">
      <CalloutTitle>
        Info
      </CalloutTitle>

      <CalloutDescription>
        When your app is released to production, set the log level to `RtmLogLevel.info`.
      </CalloutDescription>
    </CalloutContainer>

    ### Encryption configuration [#encryption-configuration]

    For enhanced security, you can enable client-side encryption:

    ```tsx

    const encryptionConfig = {
     encryptionMode: RtmEncryptionMode.aes128Gcm, // or RtmEncryptionMode.aes256Gcm
     encryptionKey: 'your_encryption_key', // 32-character string
     encryptionSalt: new Uint8Array(32), // 32-byte salt
    };

    const client = createAgoraRtmClient(
     new RtmConfig({
       userId: 'your_userId',
       appId: 'your_appId',
       useStringUserId: true,
       encryptionConfig: encryptionConfig, // Set encryption configuration
     })
    );
    ```

    Available encryption modes:

    | Encryption Mode               | Description                |
    | ----------------------------- | -------------------------- |
    | `RtmEncryptionMode.none`      | No encryption (default)    |
    | `RtmEncryptionMode.aes128Gcm` | AES 128-bit GCM encryption |
    | `RtmEncryptionMode.aes256Gcm` | AES 256-bit GCM encryption |

    ### Complete configuration example [#complete-configuration-example]

    Here's a comprehensive example showing all configuration options:

    ```tsx

     createAgoraRtmClient,
     RtmConfig,
     RtmAreaCode,
     RtmProtocolType,
     RtmLogLevel,
     RtmEncryptionMode
    } from 'agora-react-native-rtm';

    const logConfig = {
     filePath: './logs/',
     fileSizeInKB: 1024,
     level: RtmLogLevel.info,
    };

    const encryptionConfig = {
     encryptionMode: RtmEncryptionMode.aes256Gcm,
     encryptionKey: 'your_32_character_encryption_key',
     encryptionSalt: new Uint8Array(32),
    };

    const client = createAgoraRtmClient(
     new RtmConfig({
       userId: 'your_userId',
       appId: 'your_appId',
       useStringUserId: true,
       areaCode: RtmAreaCode.as,
       protocolType: RtmProtocolType.tcpUdp,
       presenceTimeout: 300,
       logConfig: logConfig,
       encryptionConfig: encryptionConfig,
     })
    );
    ```

    ## Reference [#reference-5]

    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](../../reference/firewall)

    
  
      
  
      
  
      
  
