AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER

5.2k views Asked by At

I am having issue joining a channel. I am making us of agora-web-sdk-ng.

Below is my code to join a channel:

  async startVideoStream() {

    this.rtc.client = AgoraRTC.createClient({ mode: "live", codec: "h264", role: 'host' });

    const uid = await this.rtc.client.join(this.options.appId, this.options.channel, this.options.token || null);

    this.rtc.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack();
    this.rtc.localVideoTrack = await AgoraRTC.createCameraVideoTrack();
    this.rtc.localVideoTrack.play('streamVideo')
    await this.rtc.client.publish([this.rtc.localAudioTrack, this.rtc.localVideoTrack]);

  }

But for unknown reasons, I keep on getting this error:

core.js:4197 ERROR Error: Uncaught (in promise): AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER: invalid token, authorized failed data: {"retry":false} at resolvePromise

1

There are 1 answers

3
Passersby On

I think the token needs to be the first param for that join call:

const uid = await this.rtc.client.join(this.options.token || null, this.options.channel, this.options.appId);

https://docs.agora.io/en/faq/API%20Reference/web/interfaces/agorartc.client.html#agorartc.client.html#join