The API documentation will tell you which event to listen. However DTLS “close” event may happen or not depending on whether the client had a chance to send DTLS CLOSE packet or not so you should not rely on it.
Don’t rely on your media servers to tell you, that will report false positives when a user lags or has issues connecting. Instead rely on your signaling setup to know the state of which a user is in and is wanting of the server.
So if it’s a chat server (ran on websockets), you would determine through that signaling method if a user is requesting, connecting, connected, producing a broadcast and if they left the room, stopped broadcasting/etc.
No easy answer but you shouldn’t rely on the media servers in that regards.
You could however and I use this method is, if a user has producing glitches occur; you could tell the transport to self destruct if no connection was made initially in the first 15 seconds or something. This helps my broadcasters know if they have a glitch in their video/audio capture through chrome/FF tasks. This just tells the user their producing/consumption could not occur right now, re-try type deal.
For re-starting ICE, I only allow for it if the user has established a DTLS state connected at least once, otherwise it’s a failed transport connection. All this managed at the chat server level for myself however. With ICE restarting allowed, I limit it big-time to like 1 call a user every 20-30 seconds+; users lagging will refresh if it’s so bad or wait it out so I don’t spam that.
Thanks @BronzedBroth for the detailed answer. Your method is indeed very helpful.
However I think SFU should send the state if the client transport is disconnected or SFU should do some ping pong like thing with transports. And if timeout hit it should emit the event with timeout hit message or something like that.
DTLS connection state will reveal all, but as suggested you should not be using this to accurately determine what it is the user is requesting. Sometimes the user may not be requesting anything and DTLS state changes, so it’s not reliable at all in those regards.
If you had a user lag big time, and DTLS state shows disconnected you could be tricked into thinking they left the chat or something invalid.
It’s best to reference the DTLS to assist connections that need help, as disconnected can mean anything. Knowing that the chat server will inform the media server of users leaving or closing broadcasts we can assume disconnected for us means error(if first connect is not made) or more ice if we had connected already prior.