Best practice to handle network disconnection

194 views
Skip to first unread message

Haitao Li

unread,
Nov 3, 2020, 2:39:42 AM11/3/20
to discuss-webrtc
My team is integrating WebRTC into our products on web, iOS and Android. I'm working on iOS code. I was able to link GooglWebRTC library into the project and connect to an "echo" service. The next step is to handle network disconnection/reconnection since it's going to happen a lot on mobile devices. I tested on simulator by disconnecting then reconnecting wifi after the peer connection has been established. Here is what I found:

After wifi is disconnected, the peer connection goes into "disconnected" state immediately, then "failed" after a few seconds. If I reconnect before "failed" state, then the call can resume automatically. So I suppose I don't need to handle that case. If I reconnect immediately after "failed", there is a good chance the call can resume. But if I wait a few seconds after "failed", then it doesn't reconnect. 

My questions:
1. Is there some "best practice" for handling network disconnections across all platforms?
2. How do I tell if I should re-connect in my code? GoogleWebRTC can handle reconnections sometimes. But after the "failed" state, I have no idea if the library can automatically reconnect.
3. Is it even a good idea to reconnect? I've tried using "iceRestart" flag. But sometimes the echo server I'm testing with gets into a strange state. It appears that the reconnection was successful (server doesn't send the greeting after a fresh connection), but the echo doesn't actually work. I haven't looked at the server side to figure out what exactly happened. It's also possible there is some error in audio channel so I simply don't hear anything.

Thanks

Reply all
Reply to author
Forward
0 new messages