# Assign user to subsession returning Internal Error

**URL:** <https://devforum.zoom.us/t/assign-user-to-subsession-returning-internal-error/98252>\
**Category:** Web\
**Created:** [November 13, 2023, 4:19am UTC](https://devforum.zoom.us/t/assign-user-to-subsession-returning-internal-error/98252 "2023-11-13T04:19:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![godwin.owonam](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/godwin.owonam/32/53602_2.png) [@godwin.owonam](https://devforum.zoom.us/u/godwin.owonam)\
**Post date:** [November 13, 2023, 4:19am UTC](https://devforum.zoom.us/t/assign-user-to-subsession-returning-internal-error/98252/1 "2023-11-13T04:19:10Z")

</div>

**Description**  
I am experiencing some issue when I call the ssClient.openSubsessions() function. The issue is that the users in the unassignedUserList never get reassigned to another subsession. So I tried to get the unassignedUserList and and iterate over the list and called the assignUserToSubsession(userId, subsessionId) function below.

const openSubsessions = useCallback(async () =\> {  
if (ssClient) {  
ssClient.openSubsessions(subsessions, options);  
setSubsessionStatus(SubsessionStatus.InProgress);

```
  console.log('sub status', subsessionStatus);
  console.log('ssclient stat', ssClient.getSubsessionStatus());
  

  await assignUnassignedUsersToAnyRunningSubsessions();
}

```

}, [ssClient, subsessions, options, subsessionStatus, assignUnassignedUsersToAnyRunningSubsessions]);`

const assignUnassignedUsersToAnyRunningSubsessions = useCallback(() =\> {  
console.log(‘not in any sub sessions’, unassignedUserList);  
console.log(‘available subsessions’, ssClient?.getSubsessionList());  
setSubsessionStatus(SubsessionStatus.InProgress);

```
if(ssClient) {
  if(unassignedUserList.length && ssClient.getSubsessionList().length) {
    const availableSubSessions = ssClient.getSubsessionList();
    unassignedUserList.forEach((user) => {
      const targetSubSession = Math.floor(Math.random() * availableSubSessions.length);
      const targetSubsessionId = availableSubSessions[targetSubSession].subsessionId;
      console.log('target sub', targetSubSession);
      console.log('target sub sub', availableSubSessions[targetSubSession]);
      
      assignUserToSubsession(
        user.userId,
        targetSubsessionId,
        user.displayName,
      );
    });
  }
}

```

}, [unassignedUserList, ssClient, assignUserToSubsession]);`

const assignUserToSubsession = useCallback(  
(userId: number, subsessionId: string, displayName: string, avatar?: string) =\> {  
console.log(‘sub status’, subsessionStatus);

```
  if (subsessionStatus === SubsessionStatus.InProgress) {
    if (ssClient) {
      ssClient.assignUserToSubsession(userId, subsessionId);
      console.log('passed, supposed success');
    }
  }
  setSubsessions(
    produce((subsessions: Subsession[]) => {
      const subsession = subsessions.find((r: Subsession) => r.subsessionId === subsessionId);
      if (subsession) {
        subsession.userList.push({
          userId,
          displayName,
          avatar,
          isInSubsession: false
        });
      }
    })
  );
},
[ssClient, subsessionStatus]

```

);`

But when I call the assignUserToSubsession, it doesn’t run the block below within the function. From the console logs which I had put within the **assignUnassignedUsersToAnyRunningSubsessions** function it showed that the subsessionStatus was not equal to SubsessionStatus.InProgress, even when I changed the state within the assignUnassignedUsersToAnyRunningSubsessions function.

`if (subsessionStatus === SubsessionStatus.InProgress) { if (ssClient) { ssClient.assignUserToSubsession(userId, subsessionId); console.log('passed, supposed success'); } }`

If I try to silence the check in the block above in order to let the `sscClient.assignUserToSubsession` function run by all means, it returns an `INTERNAL ERROR ` with no message.

This is not a good behaviour for us and I hope you can help me resolve it. Our project is already beyond deadline and it seems we only keep running into these issues.

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [November 14, 2023, 3:11am UTC](https://devforum.zoom.us/t/assign-user-to-subsession-returning-internal-error/98252/2 "2023-11-14T03:11:32Z")

</div>

Hey @godwin.owonam

Thanks for your feedback.

I noticed that you are calling the `ssClient.assignUserToSubsession` method immediately after the `ssClient.openSubsessions` method without waiting for it to resolve. This might be the cause of the issue you are facing.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![godwin.owonam](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/godwin.owonam/32/53602_2.png) [@godwin.owonam](https://devforum.zoom.us/u/godwin.owonam)\
**Post date:** [November 14, 2023, 11:38am UTC](https://devforum.zoom.us/t/assign-user-to-subsession-returning-internal-error/98252/3 "2023-11-14T11:38:04Z")

</div>

Hi @vic.yang

I used await to resolve the `ssClient.assignUserToSubsession` method (which I already tried before now), and it seemed to work, and then suddenly it stopped working again.  
This is very depressing.

Is there any explanation as to why this is unstable, because I have used async and await to try to resolve every method that returns a Promise/ExpectedResult

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [November 15, 2023, 4:12am UTC](https://devforum.zoom.us/t/assign-user-to-subsession-returning-internal-error/98252/4 "2023-11-15T04:12:52Z")

</div>

Hey @godwin.owonam

It might take some time for all the subsessions to open. So, waiting for the `ssClient.assignUserToSubsession` method to resolve is always the correct approach.

I’m not sure what’s happening in your case. Could you please integrate the client-side telemetry and send us the logs?

> **[Video SDK - web - Service quality](https://developers.zoom.us/docs/video-sdk/web/quality/#report-issues-to-zoom)**
>
> The Zoom Developer Platform is an open platform that allows third-party developers to build applications and integrations upon Zoom’s video-first unified communications platform.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![godwin.owonam](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/godwin.owonam/32/53602_2.png) [@godwin.owonam](https://devforum.zoom.us/u/godwin.owonam)\
**Post date:** [November 15, 2023, 2:19pm UTC](https://devforum.zoom.us/t/assign-user-to-subsession-returning-internal-error/98252/6 "2023-11-15T14:19:07Z")

</div>

@vic.yang  
Once again thanks for your response. I have added the telemetry id, as well as the global tracing.

The Sub-session logic began to work again without doing anything more, so I would like to ask, if possible, to share a link where I can read more on this so I can handle the issues better wrt to sub-sessions. Because as of now, I can’t really tell why and why not it works and then fails. I’m keen on this because our company uses the Zoom SDKs a lot in their projects. Thanks.

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [November 16, 2023, 7:12am UTC](https://devforum.zoom.us/t/assign-user-to-subsession-returning-internal-error/98252/7 "2023-11-16T07:12:08Z")

</div>

Hey @godwin.owonam

Glad to hear that the issue has been resolved.

We haven’t provided a detailed description of subsession-related resources yet, only a simple functional guide. You can find it here:

> **[Video SDK - web - Subsessions](https://developers.zoom.us/docs/video-sdk/web/subsessions/)**
>
> The Zoom Developer Platform is an open platform that allows third-party developers to build applications and integrations upon Zoom’s video-first unified communications platform.

Additionally, we have a more complex subsession sample available on GitHub that you can refer to:

> <https://github.com/zoom/videosdk-web-sample/tree/master/react-demo>
>
> //github.com/zoom/videosdk-web-sample/tree/master/react-demo

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [December 16, 2023, 5:12pm UTC](https://devforum.zoom.us/t/assign-user-to-subsession-returning-internal-error/98252/8 "2023-12-16T17:12:53Z")

</div>

Closed on December 16, 2023, 5:12pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
