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

我可以使用来自 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 访问令牌


天涯尽头无女友
浏览 94回答 1
1回答

隔江千里

CANNOT_MEET_AREA_DEMAND通常出现在以下情况:连接失败,因为用户不在选择的连接区域。比如你设置ClientConfig.areaCode为[AgoraRTC.AREAS.EUROPE],北美的用户尝试加入频道,就会出现这个错误。如果不显式设置ClientConfig.areaCode,SDK会默认请求跨地域的服务器,并选择最优连接,所以当用户加入频道时控制台日志可能会打印此错误。在这种情况下,您可以忽略该错误。尝试将 areaCode 设置为 GLOBAL:this.rtc = AgoraRTC.createClient({  //  areaCode: ['GLOBAL']});
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript