# How to keep session alive after the last participant disconnected?

**URL:** <https://openvidu.discourse.group/t/how-to-keep-session-alive-after-the-last-participant-disconnected/1712>\
**Category:** Issues developing apps\
**Tags:** v2\
**Created:** [August 4, 2020, 8:42am UTC](https://openvidu.discourse.group/t/how-to-keep-session-alive-after-the-last-participant-disconnected/1712 "2020-08-04T08:42:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timor\_Sulimani](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/timor_sulimani/32/841_2.png) [@Timor\_Sulimani](https://openvidu.discourse.group/u/Timor_Sulimani)\
**Post date:** [August 4, 2020, 8:42am UTC](https://openvidu.discourse.group/t/how-to-keep-session-alive-after-the-last-participant-disconnected/1712/1 "2020-08-04T08:42:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [August 4, 2020, 11:05am UTC](https://openvidu.discourse.group/t/how-to-keep-session-alive-after-the-last-participant-disconnected/1712/2 "2020-08-04T11:05:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Timor\_Sulimani](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/timor_sulimani/32/841_2.png) [@Timor\_Sulimani](https://openvidu.discourse.group/u/Timor_Sulimani)\
**Post date:** [August 13, 2020, 5:16am UTC](https://openvidu.discourse.group/t/how-to-keep-session-alive-after-the-last-participant-disconnected/1712/3 "2020-08-13T05:16:38Z")

</div>

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’

---

<div class="post-metadata">

**Author:** ![CSantosM](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/csantosm/32/16_2.png) [@CSantosM](https://openvidu.discourse.group/u/CSantosM)\
**Post date:** [August 13, 2020, 7:45am UTC](https://openvidu.discourse.group/t/how-to-keep-session-alive-after-the-last-participant-disconnected/1712/4 "2020-08-13T07:45:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Timor\_Sulimani](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/timor_sulimani/32/841_2.png) [@Timor\_Sulimani](https://openvidu.discourse.group/u/Timor_Sulimani)\
**Post date:** [August 13, 2020, 8:40am UTC](https://openvidu.discourse.group/t/how-to-keep-session-alive-after-the-last-participant-disconnected/1712/5 "2020-08-13T08:40:31Z")

</div>

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