Hi I'm trying to build app with webRTC and I' m little confused about how the webRTC handle the turn server .
I do understand that in establishing connection step if the network environment is not for p2p connection , they build peer connection with Turn server .
but I'm curious that in establishing connection step, if two peer had p2p connection succesfully and create PeerConnection with it. and later one of peer's network environment has changed and their PeerConnection has failed at this situation does webrtc use Turn server by itself?
or just raise PeerConnection failed and we have to do something about it?
thanks for advance for reading this..
i'm trying to build a turn server but it seem's to take some time . and i wanted to know about this feature advance . so it may help prevent to build wrong code
If direct connection is impossible, browser (or any other WebRTC client) will use TURN without any activity from the developer. There is no need to create a separate RTCPeerConnection for TURN, existing one will be used. In general, the only one thing you need to enable TURN functionality is to provide TURN server credentials in RTCPeerConnection constructor. AFAIK, there is no reliable public TURN servers, so you should deploy and configure CoTURN yourself.
If network conditions of person in the call will be changed and old IP/port will become unavailable, ICE Connection state will fall to "failed" and you can call restartICE (https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/restartIce) to re-negotiate the connection. After the negotiation, media flow will switch to direct p2p, if its possible, or will use TURN otherwise.