sessionDisconnected event invoke multiple times, what can be reasons for this?


I close session using REST-API, Everything is fine in server side. But in the client side - sessionDisconnected event invoke multiple times!
I like to mention, when i stream only camera it works fine(means sessionDisconnected event trigger only once). But if i share screen, sessionDisconnected event trigger two times for camera session!
What can be possible reasons for this problems ?
Thank’s

If you are publishing a camera and at the same time publishing a screen, then it is normal to have 2 sessionDisconnected events. There’s no official support for publishing multiple Publisher objects per connected user yet, so the “hack” to have multiple publishers in the same session is to actually have 2 different connections to the session. It’s like there are two users connected to the session, so you’ll receive 2 sessionDisconnected events.

I create two separate session, cameraSession for publishing camera and screenSession for publishing screen. when i publish both camera + screen, sessionDisconnected for cameraSession invoke two times, and screenSession is disconnected with reason network disconnected.
Is there any way to destroy or remove all instances related to a particular session manually from client side ?


Here is my frontend UI, i create two separate session - one for screen share & one for camera stream.
Using once instead of on i solve the problem, twice invoke of sessionDisconnected event.

this.cameraSession.once('sessionDisconnected', event => {
   //.....
})

But the problem is the error of Websocket is already in closing state..... And when i end stream, cameraSession disconnected properly with valid reason - sessionClosedByServer, but screenSession doesn’t.
Here is the complete log when i click End Stream Button.

And here is the complete log when i click End Stream