If my kurento media server (S1) setup on a public server, And user A can connect to S1,but it is slowly! I want to buy one host (H1) that user A connect to H1 fastly! Server H1 connect to S1 fastly!So I think install coturn on H1 as a media relay. Can I install coturn on H1,and force to traffic user A media stream through H1's coturn?
Asked
Active
Viewed 1,521 times
2
-
2Possible duplicate of [WebRTC: force peers to use TURN server](http://stackoverflow.com/questions/27224008/webrtc-force-peers-to-use-turn-server) – mido Mar 21 '16 at 04:03
-
use a custom onicecandidate, and ignore non coturn ice candidates... – mido Mar 21 '16 at 04:04
1 Answers
6
Set iceTransportPolicy: "relay"
in your peer connection config to force TURN:
var pc = new RTCPeerConnection({
iceTransportPolicy: "relay",
iceServers: [{ urls: "turn:12.254.1.52", username:"you", credential:"pwd" }]
});

jib
- 40,579
- 17
- 100
- 158
-
Thank for your reply,But perhaps because of the peer connection is not behind NAT,It seems that "media stream traffic" is not work,I get the comment " RTCIceTransportPolicy Enum As noted in [JSEP] (section 4.1.1.), if RTCIceTransportPolicy is specified, it causes the browser to only surface the permitted candidates to the application, and only use those candidates for connectivity checks." \n It only use for connectivity check? – johnny_wang Mar 22 '16 at 04:19
-
It filters out all ICE candidates except those to the TURN server, which means the peers will connect over the TURN server (assuming it is configured correctly). Sorry, I'm no expert on media server setup, nor do I comprehend why you would get any speed increase from routing data through TURN server, when the end-point is another server. TURN is usually a choice of last resort, when a direct connection cannot be established because of NATs. – jib Mar 22 '16 at 04:40
-
I want to optimize media stream traffic speed between TURN server and media server ,It is very slowly that user connect to media server directly, User connect to TURN server fast,and TURN server connect to media server fast – johnny_wang Mar 22 '16 at 05:32
-
@johnny_wang even with Trickle ICE it takes long? Relaying your traffic through TURN might speed up the connection time, but it will make you use another server for relaying. Perhaps you can move onto srflx candidates after that. Some providers do that optimization. – igracia Apr 12 '16 at 07:21
-
-
From the `iceTransportPolicy` [docs](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection), `"relay":Only ICE candidates whose IP addresses are being relayed, such as those being passed through a STUN or TURN server, will be considered.`. Shouldn't STUN still work with `"relay"`? – Ben Butterworth Jul 06 '22 at 13:13