How to keep session alive after the last participant disconnected?

As per current session behaviour,

After the last participant disconnected, the session will be automatically expired.

In our use case we need to have a small amount of NEVER expired sessions.

Is there any kind of configuration to keep the session alive forever?

No, there isn’t. Sessions will always be closed after last participant disconnect. But you can make use of customSessionId property when initializing your session in order to have total control over it.
For example, if you force your Session to be identified by string MySession, even if that specific Session instance is closed after last participant leaves, you can always re-initialize it with the exact same customSessionId. You just have to add a little control in your application’s backend:

  • If Session MySession exists, then do whatever you want with it.
  • If it doesn’t but it should (this is the case of interest for you), you just initialize it again with the same customSessionId. At all effects, for your users it will seem that the session never closed.
1 Like

There is a Session, but it expired.

So when i create a new session ====> openVidu.createSession(properties);
should i pass to properties a customSessionId?
Then when it expired, i’ll do it again?
For the last couple of days i’m trying to think where to set the ‘customSessionId’

https://docs.openvidu.io/en/2.15.0/api/openvidu-node-client/interfaces/sessionproperties.html

Wow thanks didn’t come across this.
makes everything clear!
Thanks!!