Session Lifecycle

What is the life cycle of a session? Openvidu deletes sessions if there is no transmission?
Openvidu eliminates transmissions at some point?

Hi,

OpenVidu automatically closes a session after last participant connected to it leaves the session.
So: you create a session using API REST (POST /api/sessions). That session is ready to produce tokens (POST /api/tokens), that then can be used by users to connect to it. After first user connects to it with a token, we can say that the session is “active”. More users can connect to it, recordings can be started…

Consulting sessions with API REST (GET /api/sessions) will return all created sessions (sessions with no connected users yet, and “active” sessions with connected users).

After last of the users leaves (that is, the number of users connected goes from >=1 to 0), the session is automatically closed. Except if it is currently being recorded. If so, a countdown of 2 minutes starts, and if it ellapses without new users connecting to it, the recording is stopped and the session if finally closed (the countdown time can be configrued with a global parameter. You can learn more about this here.

If this post is related to this one, OpenVidu 2.11.0 and below has a known bug that may cause some sessions to enter a “ghost” state in which the are not eliminated once last user disconnects. This has been addressed for release 2.12.0 (coming very soon) and luckly it will be solved.

That being said, if you have any information on how to actively reproduce the error in 2.11.0, it would be very useful to check that it doesn’t happen anymore in the current dev branch.

Best regards!

1 Like

Perfect, thank you very much, that helped me a lot

@pabloFuente, I faced the situation where Session is not getting closed automatically however I face this with some of the sessions only.

There was 1 Publisher and approx 50 subscribers in a session and recording was ON in Individual Mode. Once Teacher ended the session, Teacher and all subscribers got disconnected expect 1 subscriber.
When i checked it from inspector panel i found it was showing 1 connection (Without any Role i.e. Publisher, Subscribers e.t.c) . I have set Recording auto stop time to 10 Minutes.
I waited for approx 50 minutes but neither Recording nor the Session stopped. I had to disconnect this users manually.
Please explain when and how this session will get destroyed? Because if session does not get destroy automatically then Recording won’t be generated in these case.

1 Like

Hello,

You can force the closing of the session when the Teacher ends the session using this REST API method: https://docs.openvidu.io/en/2.15.0/reference-docs/REST-API/#delete-apisessionsltsession_idgt

Cheers!

@mihailj Yes, Fore closing option is there but i faced the situation where Delete Session API sometimes return 500 Internal server error and does not close the session. This is one of the Random problem which i’ve faced so far with Openvidu, any idea about the issue which i have raised here

1 Like

It seems like if a session is created and no tokens are requested, it will stay open indefinitely.

However, once a single token has been added, if nothing happens, the token will time out which looks like the participant has left–triggering the session to be closed.

Is that correct? It feels like this could be happening in my testing.