igorpavlov
igorpavlov

Reputation: 3626

WebRTC connection - STUN and TURN at the same time?

2 different computers, 2 Chromes, 2 different networks.

I am making a WebRTC call between 2 peers described above and using getStats() to check the connection. The thing is that in one Chrome it shows "turn" in "connection" property and on another it shows "stun".

Is that possible? I thought you either connected through one or another?

Upvotes: 3

Views: 1358

Answers (2)

Palash Borhan Uddin
Palash Borhan Uddin

Reputation: 394

Usually Relay candidate selected in both end is rare scenario, for the relay cases most of the time you will end up with relay candidate in one end and server-reflexive/peer-reflexive candidate in other end, though the server-reflexive/peer-reflexive candidate selected end is identifying itself as STUN or peer-to-peer candidate but its actually relay connection, best thing is to detect your original connection type is to check the candidate type of your both end.

Upvotes: 0

Antonin M.
Antonin M.

Reputation: 1784

Yes it is possible.

The first browser will use the ICE Candidate retrieved by its TURN server. The second browser will use the ICE Candidate retrieved by STUN (eg. Public IP address).

In fact, TURN servers don't have to relay WebRTC flows to a remote TURN server. If the peer is able to contact the distant TURN server without using its TURN then only one relay server will be used for the communication.

However, you can use the following option "iceTransports": "relay" in the configuration of your RTCPeerConnection of your webapp to force both browser to use a TURN server.

Upvotes: 3

Related Questions