# Use a string user ID (/en/realtime-media/rtc-server-sdk/build/build-core-media-features/stringuid/linux-java)

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

The Agora Server Gateway supports both integer and string user IDs. This page shows you how to use string user IDs.

## Implementation

1. When initializing the `AgoraService` object, call `AgoraServiceConfiguration.setUseStringUid(1)`.

   ```java
   // Create an AgoraService object
   AgoraService service = new AgoraService();
   if (null == service) {
       System.out.printf("createAndInitAgoraService fail\n");
       return;
   }
   AgoraServiceConfig config = new AgoraServiceConfig();
   // Disable the audio device module (Normally we do not directly connect audio capture or playback devices to a server)
   config.setEnableAudioDevice(0);
   // Enable the audio processing module
   config.setEnableAudioProcessor(1);
   // Enable video
   config.setEnableVideo(1);
   // Enable user ID in String format
   config.setUseStringUid(1);
   int ret = service.initialize(config);
   if (ret != 0) {
       System.out.printf("createAndInitAgoraService AgoraService.initialize fail ret=%d\n", ret);
       return;
   }
   service.setLogFile("agorasdk.log",10*1024);
   ```

2. Call `connect` to connect to the Video SDK channel.

   ```java
   RtcConnConfig ccfg = new RtcConnConfig();
   ccfg.setAutoSubscribeAudio(0);
   ccfg.setAutoSubscribeVideo(0);
   ccfg.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);
   ccfg.setClientRoleType(Constants.CLIENT_ROLE_BROADCASTER);
   AgoraRtcConn conn = service.agoraRtcConnCreate(ccfg);
   if (conn == null) {
       System.out.printf("AgoraService.agoraRtcConnCreate fail\n");
       return;
   }
   conn.connect(token, "demo_channel", "1");
   ```

## Limitations

* Enabling string user IDs when initializing `AgoraService` takes effect only after connecting to a channel. Before connection, the SDK defaults to integer user IDs. This means that you cannot subscribe to non-numeric user IDs. Ensure that any user ID you `subscribe` to before connection include only numbers. After connection, you can subscribe to user IDs with other characters.

* String user IDs can only communicate with other string user IDs. If a channel contains both string and integer user IDs, unknown errors may occur.

* Unlike integer user IDs, you must specify the string `userId` parameter in the `connect` method. If you set it to null, you receive an error.

* A string user ID must be unique within each channel.

## Supported character set

* Integer user IDs

  * 10 digits: 0-9

* String user IDs

  * Lowercase English letters
  * Uppercase English letters
  * 10 digits: 0-9
  * The space character
  * `"!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","`

    
  
