为了账号安全,请及时绑定邮箱和手机立即绑定

获取服务器节点失败 [CANNOT_MEET_AREA_DEMAND]

获取服务器节点失败 [CANNOT_MEET_AREA_DEMAND]

天涯尽头无女友 2023-03-18 17:28:00

我可以使用来自 agora.io 的临时令牌进行基本视频通话,但是当我从我的服务器创建令牌时,出现此错误。我正在使用 NgxAgora 数据包。我尝试设置区号,但在 NgxAgora 中没有此选项。这是我的角度代码:


 this.api.getmethod("appointment/gettoken/" + atob(this.acRouter.snapshot.params.id)).subscribe((data) => {

    this.token = data['token']

    this.client = this.ngxAgoraService.createClient({ mode: 'rtc', codec: 'h264' });

    

   

    this.assignClientHandlers();

  

    this.localStream = this.ngxAgoraService.createStream({ streamID: this.uid, audio: true, video: true, screen: false });

    this.assignLocalStreamHandlers();

    // Join and publish methods added in this step

    this.initLocalStream(() => this.join(uid => this.publish(), error => console.error(error)));

  })

我使用 C# 在 web api 端使用这个函数:


 public string createagoratoken(string appointmentUid,DateTime appointmentDate,int appointmentId)

    {

        var tokenbuilder = new AgoraEntegration.Media.AccessToken(AgoraEntegration.AgoraEnums.AppEnums.appId, AgoraEntegration.AgoraEnums.AppEnums.appCertificate, appointmentUid, appointmentId.ToString());


        appointmentDate = appointmentDate.AddMinutes(20);


                    

        Int32 unixTimestamp = (Int32)(appointmentDate.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;


        tokenbuilder.addPrivilege(AgoraEntegration.Media.Privileges.kJoinChannel, (uint)unixTimestamp);

        tokenbuilder.addPrivilege(AgoraEntegration.Media.Privileges.kInvitePublishAudioStream, (uint)unixTimestamp);

        tokenbuilder.addPrivilege(AgoraEntegration.Media.Privileges.kInvitePublishVideoStream,(uint)unixTimestamp);

        string token = tokenbuilder.build();

        return token;


    }

我还使用这个库作为 C# 的访问令牌 Github 访问令牌


查看完整描述

1 回答

?
隔江千里

TA贡献1687条经验 获得超10个赞

CANNOT_MEET_AREA_DEMAND通常出现在以下情况:连接失败,因为用户不在选择的连接区域。比如你设置ClientConfig.areaCode为[AgoraRTC.AREAS.EUROPE],北美的用户尝试加入频道,就会出现这个错误。如果不显式设置ClientConfig.areaCode,SDK会默认请求跨地域的服务器,并选择最优连接,所以当用户加入频道时控制台日志可能会打印此错误。在这种情况下,您可以忽略该错误。


尝试将 areaCode 设置为 GLOBAL:


this.rtc = AgoraRTC.createClient({

  //

  areaCode: ['GLOBAL']

});


查看完整回答
反对 回复 3天前
  • 1 回答
  • 0 关注
  • 8 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信