我们正在实施 Agora 屏幕共享并收到错误 DYNAMIC_USE_STATIC_KEY

We are implementing the Agora screen sharing and getting error DYNAMIC_USE_STATIC_KEY

我无法理解当前使用演示代码的错误含义

我用来共享屏幕的示例代码,我还安装了共享屏幕所需的 chrome 扩展程序

screensharing(data) {
      AgoraRTC.Logger.setLogLevel(AgoraRTC.Logger.INFO);
        var localStreams=[];
        var channelKey=null;
        if (!this._client) {
            Toast.error("Please Join First!");
            return;
        }
        const uid = this._params.uid;
        console.log("screen sharing function calling ")

        var screenClient = AgoraRTC.createClient({
            mode: 'rtc',
            codec: 'vp8'
        });
        screenClient.init(data.appID, function () {
            screenClient.join(channelKey, data.channel, null, function (uid) {
                // Save the uid of the local stream.
                localStreams.push(uid);
                // Create the stream for screen sharing.
                const streamSpec = {
                    streamID: uid,
                    audio: false,
                    video: false,
                    screen: true
                }
                // Set relevant attributes according to the browser.
                // Note that you need to implement isFirefox and isCompatibleChrome.
                if (isFirefox()) {
                    streamSpec.mediaSource = 'window';
                } else if (!isCompatibleChrome()) {
                    streamSpec.extensionId = 'minllpmhdgpndnkomcoccfekfegnlikg';
                }
              var  screenStream = AgoraRTC.createStream(streamSpec);
                // Initialize the stream.
                screenStream.init(function () {
                    // Play the stream.
                    screenStream.play('Screen');
                    // Publish the stream.
                    screenClient.publish(screenStream);

                    // Listen to the 'stream-added' event.
                    screenClient.on('stream-added', function (evt) {
                        var stream = evt.stream;
                        var uid = stream.getId()

                        // Check if the stream is a local uid.
                        if (!localStreams.includes(uid)) {
                            console.log('subscribe stream:' + uid);
                            // Subscribe to the stream.
                            screenClient.subscribe(stream);
                        }
                    })

                }, function (err) {
                    console.log(err);
                });

            }, function (err) {
                console.log(err);
            })
        });
    }

以上功能,我是调用共享屏幕

我在浏览器中收到的实际错误消息。

  • AgoraRTCSDK.min.js:2 12:01:39:329 Agora-SDK [ERROR]: [850D2] Get server node failed [DYNAMIC_USE_STATIC_KEY]
    https://webrtc2-ap-web-1.agora.io/api/v1 DYNAMIC_USE_STATIC_KEY

  • AgoraRTCSDK.min.js:2 12:01:39:331 Agora-SDK [INFO]: [850D2] Join failed: DYNAMIC_USE_STATIC_KEY

DYNAMIC_USE_STATIC_KEY当频道使用启用了证书的appid但没有传递适当的令牌时,Agora RTC SDK抛出错误,而是传递了null。

您需要使用令牌服务器生成动态令牌并将其传递到 channelKey 而不是 null

您可以在下面找到如何设置令牌服务器。 https://docs.agora.io/en/Interactive%20Broadcast/token_server_cpp?platform=CPP

或者,您可以在控制台中生成一个临时令牌 (https://sso.agora.io/en/login) 并将其传递到 channelKey 以开始开发。