gpt4 book ai didi

agora.io - 加入 channel 失败 DYNAMIC_USE_STATIC_KEY

转载 作者:行者123 更新时间:2023-12-03 23:06:29 26 4
gpt4 key购买 nike

我正在尝试使用 Agora.io 视频直播系统。但是我在开发人员控制台中收到以下错误。

点击加入按钮后出现以下错误。

Agora-SDK [ERROR]: [713FF] Get server node failed [DYNAMIC_USE_STATIC_KEY] https://webrtc2-ap-web-1.agora.io/api/v1 DYNAMIC_USE_STATIC_KEY agora.js:161:41
Agora-SDK [INFO]: [713FF] Join failed: DYNAMIC_USE_STATIC_KEY agora.js:155:41
[ERROR] : join channel failed DYNAMIC_USE_STATIC_KEY live:1146:15

我必须在 agora 管理面板上进行安排。我做错了什么。

 var rand = <?php echo rand(1111111,9999999); ?>;
var agoraAppId = 'API ID HERE'; // set app id
var channelName = "stream_<?php echo $creatorUserID;?>_"+rand; // set channel name
// join a channel
function joinChannel() {
var token = generateToken();
var userID = 0; // set to null to auto generate uid on successfull connection

// set the role
client.setClientRole('host', function() {
console.log('Client role set as host.');
}, function(e) {
console.log('setClientRole failed', e);
});

// client.join(token, 'allThingsRTCLiveStream', 0, function(uid) {
client.join(token, channelName, userID, function(uid) {
createCameraStream(uid, {});
localStreams.uid = uid; // keep track of the stream uid
console.log('User ' + uid + ' joined channel successfully');
$('#main_live_video').html('')
$('#publishBtn').removeAttr('disabled');
$('#publishBtn').text("Please Wait");
$('#publishBtn').addClass('hidden');
$('.end_vdo_call').removeClass('hidden');

$.post(requestUrl + "?f=live", {stream_name: channelName}, function(data, textStatus, xhr) {
if (data.status == 200) {
$('#live_post_id').val(data.post_id);
}
});
}, function(err) {
console.log('[ERROR] : join channel failed', err);
});
}
function generateToken() {
return null; // TODO: add a token generation
}

最佳答案

您收到的错误是因为您尝试使用启用了 token 身份验证的 AppID,但在加入 channel 时未传递 token 。

要解决这个问题,您通常有三个选择:

  1. 创建一个新项目并生成一个新的 AppID。打开Project Management tab within the Agora Console .单击屏幕左上角的“创建”按钮。在对话框中,确保选择底部选项。 enter image description here

  2. 使用 Project Management tab within the Agora Console 在您的项目上生成一个临时 token (24 小时有效) .请按照以下步骤操作:

    • 选择生成临时 token 选项 enter image description here
    • 输入 channel 名称并生成 token enter image description here
    • 使用您的 token 字符串更新 generateToken 函数,而不是返回 null。
function generateToken() {
return null; // add a token string here
}
  1. 实现 token 服务器并生成动态 token 。更多详情请查看:
function generateToken() {
return null; // add a token string here
}

第二个选项不适用于您的实现,因为您正在使用用户名生成 channel 名称并附加随机值。生成临时 token 时,您需要知道 channel 的名称。

关于agora.io - 加入 channel 失败 DYNAMIC_USE_STATIC_KEY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62357347/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com