Detect peer disconnection with WebRTC Native API

1,434 views
Skip to first unread message

San Martino

unread,
Mar 4, 2015, 2:02:06 PM3/4/15
to discuss...@googlegroups.com
Hi,

I would like to know if there is a reliable way to detect the remote peer disconnection/shutdown with the Native API.
I know the clean way is to always signal the shutdown to the other peer, but this might not be the case if, for some reasons, one peer abruptly "kills" the connection without signalling (as a concrete example, just think of a user closing his/her browser)

Basically, I would expect the "local" PeerConnectionObserver to be triggered thanks to some callbacks when the remote peer disconnection happens.
But in my test cases (LAN) this never happened. No callback is *ever* invoked when the remote peer abruptly closes his browser during an on-going video/audio streaming.

Could you give me some hints or point out the right way to detect this situation? If you could also point out the portion of code in the /peer client example, I'd appreciate it, as I could not find where/if this situation is handled.
I have been told that getStats can be helpful, but before looking deeply at it, I'd like to know if and  why  other callbacks in the observer are never called.

Justin Uberti

unread,
Mar 6, 2015, 1:40:42 PM3/6/15
to discuss-webrtc
You should get an ICE connection state change event in this case.

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

San Martino

unread,
Mar 6, 2015, 2:23:45 PM3/6/15
to discuss...@googlegroups.com
Yes, I am already aware of the fact that I should get an ICE connection state change, but I don't get it. I get it for other events, but not for the situation descrided above.
It's easy to reproduce. Run two peers in a LAN and connect them, let the first peer stream video/audio to the second peer for a while (in one direction), then "kill -9" the second peer receiving the video /audio stream. Unfortunately, you will notice the first peer will never receive any ice connection state change.

Justin Uberti

unread,
Mar 6, 2015, 7:31:06 PM3/6/15
to discuss-webrtc
Strange. Can you get a client log? The state should change to disconnected within ~5 seconds.

Kaiduan Xie

unread,
Mar 11, 2015, 2:32:00 PM3/11/15
to discuss...@googlegroups.com
I just did the same test with latest webrtc native code, OnIceConnectionChange() is triggered with disconnected state as expected.

/Kaiduan
Reply all
Reply to author
Forward
0 new messages