When closing call getting ObjecterrorCode: 5007 "INSUFFICIENT_PRIVILEGES"

(Posted on github as well)
I am getting the following error every time I close a session:

@zoom_videosdk-ui-toolkit.js?v=dc969869:33346 Uncaught (in promise)
ObjecterrorCode: 5007
reason: "only host can do the operation"
type: "INSUFFICIENT_PRIVILEGES"

This error happens only with @zoom/videosdk-ui-toolkit version 2.1.10-1, it does not happen with version 2.1.0-1

You can replicate this error with the sample apps, like the React sample app:
videosdk-ui-toolkit-react-sample
or the Angular sample app:
videosdk-ui-toolkit-angular-sample

The issue gets triggered during session cleanup, at the following instruction :

uitoolkit.closeSession(sessionContainer)

After a first call, all subsequent attempts to start a session fail.

I checked the uitoolkit test page. There this issue does not occur.
By looking at the js script, the uitoolkit.onSessionClosed callback function does not call
uitoolkit.closeSession(sessionContainer)⁠.
Instead, there is another callback that is not suggested in the documentation guides:

  ...
  uitoolkit.onSessionDestroyed(sessionDestroyed) 
  ...

  const sessionDestroyed = () => {
    console.log("session destroyed");
    uitoolkit.destroy();
  };

Questions:
Do we need to use the uitoolkit.destroy instead of uitoolkit.closeSession ?
If that is the case, I would have expected to call uitoolkit.destroy when the uitoolkit.onSessionClosed is fired.
Documentation is not clear, can you please shed some lights on this?

Hi @marcocarosi I’m taking a look at this issue with my team now. I will get back to you with an update shortly.

2 Likes

Hi @marcocarosi I’m not able to replicate this issue in our react sample app.

This is the code I am using:

async function joinSession() {
    await getVideoSDKJWT();
    console.log(config);
    if (sessionContainer) {
      uitoolkit.joinSession(sessionContainer, config);
      sessionContainer && uitoolkit.onSessionClosed(sessionClosed);
    }
  }

  const sessionClosed = () => {
    console.log("session closed");
    sessionContainer && uitoolkit.closeSession(sessionContainer);
    document.getElementById("join-flow")!.style.display = "block";
  };

Would you be able to test from that sample app and let me know if is working there?

Hi Ticorrian, thank you for you reply.
I am using the react sample app videosdk-ui-toolkit-react-sample available in github.

There the code is not exactly the one you are using (App.tsx)

  function getVideoSDKJWT() {
    sessionContainer = document.getElementById(
      "sessionContainer"
    ) as HTMLDivElement;
    document.getElementById("join-flow")!.style.display = "none";
    fetch(authEndpoint, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ sessionName: config.sessionName, role: role }),
    })
      .then((response) => {
        return response.json();
      })
      .then((data) => {
        if (data.signature) {
          console.log(data.signature);
          config.videoSDKJWT = data.signature;
          joinSession();
        } else {
          console.log(data);
        }
      })
      .catch((error) => {
        console.log(error);
      });
  }

  function joinSession() {
    console.log(config);
    if (sessionContainer) {
      uitoolkit.joinSession(sessionContainer, config);
      sessionContainer && uitoolkit.onSessionClosed(sessionClosed);
    }
  }

  const sessionClosed = () => {
    console.log("session closed");
    sessionContainer && uitoolkit.closeSession(sessionContainer);
    document.getElementById("join-flow")!.style.display = "block";
  };

I checked again with the github sample app, and the issue is still there.
Just to be sure, I also modified the original code to accommodate the async/await paradigm in your code:

  async function getVideoSDKJWT() {
    sessionContainer = document.getElementById(
      "sessionContainer"
    ) as HTMLDivElement;
    document.getElementById("join-flow")!.style.display = "none";
    return fetch(authEndpoint, {
      method: "POST",
      headers: {"Content-Type": "application/json"},
      body: JSON.stringify({sessionName: config.sessionName, role: role}),
    })
      .then((response) => {
        return response.json();
      })
      .then((data) => {
        if (data.signature) {
          console.log(data.signature);
          config.videoSDKJWT = data.signature;
          // joinSession();
        } else {
          console.log(data);
        }
      })
      .catch((error) => {
        console.log(error);
      });
  }

  async function joinSession() {
    await getVideoSDKJWT();
    console.log(config);
    if (sessionContainer) {
      uitoolkit.joinSession(sessionContainer, config);
      sessionContainer && uitoolkit.onSessionClosed(sessionClosed);
    }
  }

  const sessionClosed = () => {
    console.log("session closed");
    sessionContainer && uitoolkit.closeSession(sessionContainer);
    document.getElementById("join-flow")!.style.display = "block";
  };

But also in this case I am getting the same error:

errorCode: 5007
reason: "only host can do the operation"
type: "INSUFFICIENT_PRIVILEGES"

Again, the error occurs when you do Leave Session or End Session. And after the first session, all subsequent attempts to do Join Session bring you to an empty browser window.

Hopefully my (sorry maybe too long :smiling_face:) reply helps.

1 Like

Hi Ticorrian,
in the mean time I got a reply from endazoom, (Enda Zhang?) one of the maintainers of the zoom/videosdk-ui-toolkit-web github repository, on the bug I opened in GitHub before posting here.
It is issues #52, let me copy it here for convenience (I guess I cannot add links to this chat):

Thanks for the feedback! The closeSession() API should only be used by the session host, and it will end the session for other users. If the user role type is not host (role type not equal to 1, you will get this error). We will improve the documentation in later releases.
If you want to open another new session, please destroy the current instance first.

That confirms the need of the uitoolkit.destroy() call before creating another session.
Not sure why I am getting the error on the sample app, since the role is always 1.

Hi @marcocarosi thanks for that info! I’ll work with Enda to get this better documented. Regarding the error youre receiving, are you sure the role being passed in the signature is 1? Also, there should be a host status in the participant list when you join as a host. Can you confirm if you see that?

Hi @ticorrian.heard

@zoom/videosdk-ui-toolkit”: “^2.1.10-2”
“react”: “18.2.0”,
“react-dom”: “18.2.0”,
“volta”: {
“node”: “20.11.1”
}

I’m encountering a similar issue to the one discussed earlier. I have reviewed your suggestions and ensured that from the backend, the role_type: 1 (host) is correctly being passed during video call initiation.

{
  "app_key": "",
  "cloud_recording_option": 0,
  "exp": 1745842506,
  "iat": 1745838906,
  "role_type": 1,
  "tpc": "1444161-f5a4e4a7",
  "user_identity": "675534",
  "version": 1
}

On the frontend, in the user component, I can also see the “Host” label correctly displayed next to my user, which confirms that the role assignment appears to be working.

However, when I attempt to end or leave the call, I consistently receive the following exception:

videosdk-ui-toolkit.min.umd.js:811 Uncaught (in promise)

{
  type: 'INSUFFICIENT_PRIVILEGES',
  reason: 'only host can do the operation',
  errorCode: 5007
}

This suggests that, although I am displayed as the host, the SDK internally does not seem to recognize me as having sufficient privileges to perform host-specific operations like ending the call.

I have already tried the basic troubleshooting steps, including verifying the role assignment and ensuring that the session is properly initialized.

Could you please help me understand why this mismatch might be happening, and if there are any additional checks or configurations required on either the frontend or backend side to properly grant host privileges when joining the session?

Thanks in advance for your help!

Hi @Waqas @marcocarosi I did some more testing on this and was able to replicate the issue. It seems the issues occurs regardless of when you call the uitoolkit.closeSession(sessionContainer) method so it does not look like a race condition issue. I reached out to our tooling team to confirm this could be an underlying issue. I’ll reach back out shortly after they’ve had some time to investigate.

2 Likes

@Waqas @marcocarosi I spoke with Enda, one of engineers on the uitoolkit team, and he confirmed that uitoolkit.closeSession(sessionContainer); is not needed in the onSessionClosed listener. The reason is because the moment onSessionClose() event is fired, the session has already been ended and you cannot end a session that has been ended already.

We put in a request to update the docs to reflect this behavior and hopefully avoid future confusion.

1 Like