AgoraIO-Community / AgoraWebSDK-NG

The Next Generation of Agora Web SDK
https://agoraio-community.github.io/AgoraWebSDK-NG/
161 stars 75 forks source link

Can't rejoin channel after token has expired #134

Closed joao-p-pinto-findmore closed 3 years ago

joao-p-pinto-findmore commented 3 years ago

Describe the bug

Hello, everyone.

I am using AgoraWebSDK-NG inside a Vue.js SPA to create a voice chat room. For each user I'm issuing 10 minute tokens (although I'm currently testing with 1 minute tokens because of the expiration events). When I get the token-privilege-will-expire event, which is triggered when only 30 seconds are left, I call my Web API, generate a new token and call the renew() method on the FE with that token and everything works fine.

However, I'm not able to restart/rejoin a channel after shutting it down (i.e. stopping and closing the audio track and leaving the client) if the original token used for that channel has expired. All subsequent tokens will not work and I will always get the following error: AgoraRTCError CAN_NOT_GET_GATEWAY_SERVER: dynamic key expired data: {"retry":false}.

If I refresh the page I'm able to connect without any issue again.

I think it has to do with the renew method. Because if I leave and rejoin the call before the renew method is called, everything works fine, but after that I get the errors.

SDK Logs

I have enabled logs. This is an example of the errors I'm getting:

image

Channel: ea81473e-0cc7-429e-b6e7-d03226b76dc6

UID: 4bdb31fd-e4e1-4f79-a0ae-ebe3dd8aa6b7

Platform and Browser:
Windows 10 and Latest Chrome or Edge

SDK Version: "agora-rtc-sdk-ng": "4.3.0" on the FE "agora-access-token": "^2.0.4", on the BE

To Reproduce

Steps to reproduce the behavior:

  1. Create a client and join call.
  2. Stop call.
  3. If rejoin the call/client after the original token has expired I get the error.

Additional context

(All of this was tested on localhost, so everything is test data)

This is how I'm creating the client:

AgoraRTC.enableLogUpload();

this.rtc.client = AgoraRTC.createClient({
  mode: 'live',
  codec: 'vp8',
});

This is how I'm joining the channel:

await this.rtc.client.join(
    this.configurations.app_id,
    this.configurations.channel_name,
    this.configurations.agora_auth_token,
    this.configurations.user_id
);

I get this information after calling the BE endpoint that generates the token. The user ID is a GUID. An example configuration object is:

agora_auth_token: "006a1269e2a8cb44ee599b45559f30cf73aIAAYp4dKnImSPy9faUqCwu5+kMD3WA7YE7NH+A811pLtQXa8UtoCOtJpIgB/2A6SNtptYAQAAQDyiGxgAgDyiGxgAwDyiGxgBADyiGxg"
app_id: "XXX"
channel_name: "ea81473e-0cc7-429e-b6e7-d03226b76dc6"
user_id: "4bdb31fd-e4e1-4f79-a0ae-ebe3dd8aa6b7"
joao-p-pinto-findmore commented 3 years ago

Turns out there was some sort of memory issue on the Vue side of things that was always using the previous token which is what was causing this issue. I'm closing this since there wasn't any real issue to start with.