Detecting disconnected peers with webrtcbin

Hi everyone.
I’m using gstreamer v1.22.0.
I have setup a one way peer connection, sending only video from local (gstwebrtcbin) to remote (Browser). If the remote suddenly disappears, there seems to be no way to know about this on the sender side. I understand that it is difficult to interpret whether a connection is just temporarily interrupted or if it has actually closed down. I also know that its possible to detect this from the signalling side. However, i wonder if there is another way to detect this. The only other solution I could think of is to monitor the twcc stats. Although there doesn’t seem to be any direct way of determining whether twcc stats have stopped being received locally, i have noticed that all the stats, namely

bitrate-sent , bitrate-recv , packets-sent , packets-recv, avg-delta-of-delta ,

have exactly the same values on subsequent queries after a lost remote connection. This makes sense as the remote is no longer able to provide feedback. So once I get same values repeated for the stats over a period of time, I can assume the remote has most likely dropped as those values tend to change quite dynamically during an active session. Is there any flaw In this logic or is there a better way to do this ?

I ran into the same issue. Unfortunately there’s no simple solution but here’s what I did.

  1. You can get the rtpbin element from the webrtcbin and listen for timeouts like on-timeout
  2. The bus for the pipeline will generate errors. If you look for “SCTP association went into error state” in the error message you can detect a disconnection. See this open issue for details. https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3018

@hellofanengineer I’ll definitely look into point 1. As for your second option and referenced issue, I think i would need a data channel open for that. I suppose i could set one up if I can’t come up with another solution.

Thanks

If you have a new enough libnice version, then consent freshness will kick in after roughly 30 seconds and notify you of a disconnected peer in the ICE connection state.

@ystreet00 Thanks. I’ll check that out.