Track Removed Fired Too Late

Good day,

I developed an application with the help of lib-jitsi-meet that allows users to dynamically join a new conference on a web application, so without reloading the page. So basically, we have multiple Jitsi rooms.

I achieved this by calling the disconnect function of the JitsiConnection and creating a new JitsiConnection with the new Jitsi serviceUrl upon changing to a new room.

However, upon moving from one room to the other, the audio tag of the old connection remains in the HTML and the TRACK_REMOVED event is fired exactly 16 seconds after the CONNECTION_DISCONNECTED event happened.
This causes problems when you move back from the new room to the original one (which becomes a new Connection) under these 16 seconds since the audio track gets removed regardless. Therefore, you are unable to hear others in the old room.

I have two question regarding this:

  • Since the TRACK_REMOVED event is always fired after 16 seconds, it sounds like a configureable value but I couldn’t find the proper options in the Jitsi Handbook. So is there once?
  • Do I have to fire the TRACK_REMOVED event myself to achieve this?

I was asking in the Git repo of the lib-jitsi-meet and saghul responded that we need to call JitsiConference.leave() before closing a connection. This seems to do the trick (or show further error messages that need to be debug further)