Reputation: 37
For example I want to share media traphic with WEBRtc
.
Obviously if I want to go through NAT.
I need to use STUN/TURN
server.
And when WEBRtc
starts to share ICE
candidates - how the browser knows that STUN/TURN
server exists and it should go there first?
Thank's.
Upvotes: 1
Views: 722
Reputation: 744
WebRTC in Browser begins to analyze the status of the network connection (in fact, the standard does not indicate when to do this, and for many browsers, WebRTC starts to study the network immediately after creating the corresponding objects, so as not to create unnecessary delays when connecting). When the developer in the first steps was creating WebRTC objects, he should at least pass the address of the STUN server. This is a server that, in response to the UDP packet “what is my IP”, transmits the IP address from which this packet was received. WebRTC uses the STUN server to get an “external” IP address, compare it with an “internal” one and see if there is NAT. And if so, which reverse ports does NAT use to route UDP packets?
From time to time, WebRTC on the browser will call the onicecandidate
callback, transmitting the SIP packet with information for the second connection participant. This packet contains information about internal and external IP addresses, connection attempts, ports used by NAT, and so on. The developer uses signaling to transfer these packets between Browsers. The transmitted packet is sent to WebRTC using the addIceCandidate()
method.
After a while, WebRTC will establish a peer-to-peer connection. Or will not be able if NAT will interfere. For such cases, the developer can transmit the address of the TURN server, which will be used as an external connecting element: both browsers will transmit UDP packets with voice or video through it.
You pass STUN/TURN servers configuration when initially create RTCPeerConnection
.
Upvotes: 2