Cannot join subsessions: Websocket closed before connection is established loop

Description
I’m attempting to build a waiting room using subsessions as described in the developer blog entry “Building a telehealth waiting room with Zoom Video SDK”. If I remove all lines of code up to the .joinSubsession in the snippet below, the client successfully connects to the main session. As soon as I call .joinSubsession, the app is thrown into a connection loop that never completes. The await .joinSubsession promise never fulfills or rejects , and the logs indicated below begin appearing forever.

Browser Console Error
WebSocket connection to ‘wss://zoomiad206247136128rwg.iad.zoom.us/wc/media/95281164371?type=s&cid=5F4E0267-5E17-E02A-6054-C58FAFBE24A9&mode=1’ failed: WebSocket is closed before the connection is established.

js_media.min.js:2 handleRendererTypeInProps() final rendererType=3 gpuBlacklist=undefined

39e4ae1a-81b3-431e-9b27-22f0f800d9a7:1 Sharing Version: 3727

625b5454-3119-4a29-b1e2-c5017be63671:1 WebSocket connection to ‘wss://zoomiad206247136128rwg.iad.zoom.us/wc/media/95281164371?type=s&cid=08480093-56D4-2D7A-5218-DAE32DBADEBD&mode=1’ failed: WebSocket is closed before the connection is established.

js_media.min.js:2 handleRendererTypeInProps() final rendererType=3 gpuBlacklist=undefined

da4d9623-cd77-4ca7-88a1-8ce36be7630b:1 Sharing Version: 3727

ec6ea77d-1930-4047-8f0a-1affd63d2779:1 WebSocket connection to ‘wss://zoomiad206247136128rwg.iad.zoom.us/wc/media/95281164371?type=s&cid=764B3A9D-21A0-D309-BC20-F8F670416593&mode=1’ failed: WebSocket is closed before the connection is established.

js_media.min.js:2 Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘remoteDescription’)

js_media.min.js:2 Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘remoteDescription’)

js_media.min.js:2 Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘remoteDescription’)

js_media.min.js:2 Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘remoteDescription’)

js_media.min.js:2 Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘setRemoteDescription’)

js_media.min.js:2 handleRendererTypeInProps() final rendererType=3 gpuBlacklist=undefined

5dfb116a-14f9-4e3a-88f2-72010ae6abef:1 Sharing Version: 3727

8d0be545-e06c-49d1-8731-4ea0c880ae38:1

WebSocket connection to ‘wss://zoomiad206247136128rwg.iad.zoom.us/wc/media/95281164371?type=s&cid=CD4E3EE9-D9D2-0F0A-0296-76F3A1CE2FA7&mode=1’ failed: WebSocket is closed before the connection is established.

Which Web Video SDK version?
2.2.5

Video SDK Code Snippets

await client.join("---", "---", "---");
        const subsessionClient = client.getSubsessionClient();
        const inProgressSubsession = (
          await subsessionClient.createSubsessions(["in-progress"])
        )[0];

        if (inProgressSubsession) {
          const ownUserId = client.getCurrentUserInfo().userId;
          const subsessionList = subsessionClient.getSubsessionList();
          const session = subsessionList.find(
            (item) => item.subsessionId === inProgressSubsession.subsessionId
          );
          if (session) {
            const { userList } = session;
            if (!userList.find((user) => user.userId == ownUserId)) {
              userList.push(client.getCurrentUserInfo());
            }
          }
          await subsessionClient.openSubsessions(subsessionList, {
            isBackToMainSessionEnabled: false,
          });
          await subsessionClient.joinSubsession(
            inProgressSubsession.subsessionId
          );
          inProgressSubsessionRef.current = inProgressSubsession;

Device (please complete the following information):

  • Device: Macbook Pro
  • OS: 15.5
  • Browser: Chrome
  • Browser Version: 139.0.7258.67

Hey @apc

Thanks for your feedback.

Could you share some problematic session IDs with us for troubleshooting purposes?

Thanks
Vic

Yes of course, thank you @vic.yang.

I’ve just generated session ID (key) ab026e14-6b58-4802-827d-04dc31346a0e (Dvshw1oYR8O4t3rh78zzig==) to test this. As far as a pattern in the dashboard, every connection attempt generates a 2-3 second long participant row ie

Join Time / End Time

04:52:42 AM 04:52:45 AM

So I end up with a lot of those.

As an additional bit of info, I added this right before the join

client.on("connection-change", console.log);
          await subsessionClient.joinSubsession(
            inProgressSubsession.subsessionId
          );

And I see, tied to these websocket warnings, that it constantly repeats these two logs


{state: 'Connected'}

WebSocket connection to ... closed before the connection is established

{state: 'Reconnecting', reason: 'failover'}

Hi @apc

Dvshw1oYR8O4t3rh78zzig==

Thank you for sharing the session ID. We are investigating the root cause of the issue.

Thanks
Vic

1 Like

Hi @apc

Dvshw1oYR8O4t3rh78zzig==

We have identified some potential causes, but we still need you to confirm some information. I will DM you with the relevant questions.

Thanks
Vic

1 Like

Thanks @vic.yang , after ensuring that the token carries the typ: JWT header, we’re able to successfully connect. Odd that it worked for the main session without it.

Still encountering one strange thing behaviorally that I can work around for now, but seems like its not working as expected. If I await subsessionClient.joinSession, it never resolves. Instead, I have to subscribe to the connection change to get my code to progress.

subsessionClient.joinSubsession(inProgressSubsession.subsessionId);

            await new Promise<void>((resolve) => {
              const onConnectionChange: typeof event_connection_change = (
                payload
              ) => {
                console.log(`connection change: ${JSON.stringify(payload)}`);
                if (payload.state === ConnectionState.Connected) {
                  resolve();
                  client.off("connection-change", onConnectionChange);
                }
              };
              client.on("connection-change", onConnectionChange);
            });

Hi @apc

Thanks for your feedback.

If I await subsessionClient.joinSession , it never resolves.

It is indeed an issue; we will fix it in the upcoming release (2.2.10 – late August).

Thanks
Vic

1 Like