Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

SessionError: A session has already been opened #30

Open
MarkusPint opened this issue Feb 22, 2023 · 7 comments
Open

SessionError: A session has already been opened #30

MarkusPint opened this issue Feb 22, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@MarkusPint
Copy link

if (!VoxeetSDK.session.isOpen()) { await VoxeetSDK.session.open({ name: 'testname', externalId: 1 }); }

Intermittently this code is producing an error:
"SessionError: A session has already been opened"

How can this be possible? We've taken care to check that a session is not open before we try to open one, but still it sometimes throws this error.

@FabienLavocat FabienLavocat self-assigned this Feb 22, 2023
@FabienLavocat
Copy link
Member

Are you facing this issue in this getting started project or in your own?

@MarkusPint
Copy link
Author

In my own. I just realized this is the wrong place probably. Apologies.

@FabienLavocat
Copy link
Member

No it's all good, we can try to resolve it right here.
Could you share a bit of code to understand what could go wrong. Are you in a React application? Could you have concurrent "threads" trying to call this function at the same time?

@MarkusPint
Copy link
Author

We are using the SDK in an Angular application and in a Chrome extension.

I don't think in either of those alone concurrent calls can happen. But usually an user will open a session from both the app and the Chrome extension. So user will have 2 sessions running.

Then sometimes user will connect to a conference from the Chrome extension, and other times from the app.

Should we perhaps be using a separate externalId for the user's session in the Angular application and the Chrome extension?

@FabienLavocat
Copy link
Member

The web app and the chrome extensions should not be sharing the same context so opening a session in each should be completely fine. Using the same externalId for both session however might trigger some issues if you try to join the same conference as one session will get kicked out of the conference (you can't have the same user connected twice to the same conference).

When this issue happens, do you see any errors in the console logs of the browser? (besides that you can't open a session since one is already opened).

Could confirm if your code is calling multiple times the VoxeetSDK.session.isOpen()

@MarkusPint
Copy link
Author

It seems like there are no other related logs when this happens (I don't know how to reproduce this on my own machine, I'm seeing this happen to a few of my users via Datadog logs).

The code does call VoxeetSDK.session.isOpen() multiple times during a session.. and then it calls VoxeetSDK.session.open() if the session happens to be not open... also multiple times theoretically. But unlikely to happen concurrently and from the logs I don't see any concurrent calls within one tab.

A user can also have the Chrome extension code running in multiple tabs.. then a session per each tab.

This issue seems to be limited to a small subset of users, but it causes critical issues when it happens.

@FabienLavocat
Copy link
Member

FabienLavocat commented Feb 22, 2023

A user can also have the Chrome extension code running in multiple tabs.. then a session per each tab.

This should not have an impact as each tab (or Chrome extensions) are isolated from one another.

I suspect it could be that while the session is opening, another call to isOpen() is made and because it is not open, then it goes to the next step which is trying to open a session again.

As a workaround, until we figure out the exact problem, I would use something like that:

if (!VoxeetSDK.session.isOpen()) {
    const user = { name: 'testname', externalId: 1 };
    try {
        await VoxeetSDK.session.open(user);
    } catch (error) {
        if (error.message !== 'A session has already been opened') {
            throw error;
        }
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants