RTS TraceID is a globally unique request identifier that is used to locate and troubleshoot requests. RTS TraceID plays a vital role in improvement of access efficiency. This topic describes how to obtain an RTS TraceID.

Background information

When you troubleshoot issues during playback by using information such as the playback time and the IP address of a user, you must retrieve error logs from a large number of logs. This process is inefficient. If multiple playback behaviors occur for the same user IP address within this period of time, the O&M difficulty further increases. RTS provides a solution that uses TraceIDs. A TraceID is generated for each playback behavior, which can be used to identify the issue at the earliest opportunity. We recommend that you associate TraceIDs with your client logs.

You can use the following methods to obtain an RTS TraceID:

Obtain an RTS TraceID by using RTS demos

Use the RTS demo for Android or iOS

For information about how to use the RTS demo for mobile clients to play an RTS stream, see Run demos. After a playback request is initiated, click Troubleshoot on the playback page of the RTS demo and view the details in the pop-up window. The RequestId is the TraceID.

Use the RTS demo for web (in HTML5)

For information about how to use the RTS demo for web to play an RTS stream, see Run demos. After a playback request is initiated, click Troubleshoot on the playback page of the RTS demo and view the TraceID in the pop-up window.

Obtain an RTS TraceID in a production environment

In a production environment, the SDKs are integrated into your application and you no longer need to use the demos of Alibaba Cloud.

Android or iOS production environment

  • Only RTS SDK for .NET integrated
    1. Register the MessageCallback callback. See the example in the rtsdec.c file.
      // For details, see the rtc_read_header function in the rtsdec.c file.
      __rts_funcs->preconfig("MessageCallback", addr_to_string(format_control_message, buf));
      __rts_funcs->preconfig("MessageCbParam", addr_to_string(s, buf));
    2. Parse the data parameter in the callback, listen to the event whose code is 104, and then obtain the helpid and TraceID.

      In the following sample code, the TraceID is live6.cn1026_3166_317379681_164568568****.

      "code=104,when=1645685687551,where=na,who=0,desc=\"trace:d2acbcdc%252D6bc0%252D4353%252D9070%252De37d73e34761-pull%2Ertspk%2Egrtn%2Ealiyunlive%2Ecom-ios-20220224065447-F4h9naPqJ6GDzwPV-sub-live6.cn1026_3166_317379681_164568568****\""
  • RTS SDK integrated through ApsaraVideo Player
    1. Register the callback.
      • For Android: Register setOnInfoListener of IPlayer.
      • For iOS: Register -(void)onPlayerEvent:(AliPlayer*)player eventWithString:(AVPEventWithString)eventWithString description:(NSString *)description of AVPDelegate.
    2. Parse the string in the callback.
      • For Android: With infoBean.getCode() == InfoCode.DirectComponentMSG, parse infoBean.getExtraMsg(), listen to the event whose code is 104, and then obtain the helpid and TraceID.
      • For iOS: With eventWithString == EVENT_PLAYER_DIRECT_COMPONENT_MSG, parse description, listen to the event whose code is 104, and then obtain the helpid and TraceID.

        In the following sample code, the TraceID is live6.cn1026_3166_317379681_164568568****.

        {"class":"demuxer","obj":"10804120096","name":"ArtcDemuxer","level":16,"content":"code=104,when=1645685687551,where=na,who=0,desc=\"trace:d2acbcdc%252D6bc0%252D4353%252D9070%252De37d73e34761-pull%2Ertspk%2Egrtn%2Ealiyunlive%2Ecom-ios-20220224065447-F4h9naPqJ6GDzwPV-sub-live6.cn1026_3166_317379681_164568568****\""}

HTML5 web production environment

  • Obtain the TraceID from the response result of the signaling request

    An HTML5 signaling request is an HTTP POST request. You can obtain the TraceID from the Network tab of the developer tool in your browser. If the source URL is artc://player.alicdn.com/a/b_RTS, the signaling request is http(s)://player.alicdn.com/a/b_RTS.

    1. Access the RTS player for web.
    2. In the RTS player for web, enter the streaming URL for which RTS is enabled, for example, artc://player.alicdn.com/a/b_RTS.
    3. Click Start to play the RTS stream.
    4. Press F12 to open the developer tool of your browser and click the Network tab.
    5. Search for the http(s)://player.alicdn.com/a/b_RTS signaling request and view the TraceID in Response.
  • RTS SDK integrated into your own proprietary player
    RTS SDK can obtain all messages by registering the customReporter function. If the msgid is 126, the subscription is successful and you can obtain the TraceID. Sample code:
    AliRTS.createClient({
      customReporter: (params) => {
        const msgIds = [126/* Subscription is successful. */, 220/* Stream ingest is successful. */];
        if (msgIds.includes(Number(params.msgid))) {
          const args = JSON.parse(params.args);
          const traceId = args.tcid;
          console.log('traceId', traceId);
        }
      }
    })