How to force TURN ? (so Safari works fine)

1,265 views
Skip to first unread message

yarek chmielewski

unread,
Nov 10, 2017, 9:01:44 PM11/10/17
to meetecho-janus
It seems that safari restriction rule "you must stream to watch stream" can be bypassed if turn server are used: 


It looks like companies such as Slack forces TURN on Janus : https://webrtchacks.com/slack-webrtc-slacking/

I used that in janus.config


turn_server = numb.viagenie.ca
turn_port
= 3478
turn_type
= udp
turn_user
= yarek
turn_pwd
= ****


and also in my JS script

janus = new Janus({
        server: server,
        iceServers :[{url: 'turn:numb.viagenie.ca',
        credential: '****',
        username: 'yarek'
        }]
`,

But still cannot make safari break that rule : Is there a way to force Janus to use TURN ?

Lorenzo Miniero

unread,
Nov 10, 2017, 9:08:12 PM11/10/17
to meetecho-janus
TURN must NOT be forced on Janus... You need TURN for browsers, in this case Safari: https://janus.conf.meetecho.com/docs/FAQ#turn

L.

Jon Ruddell

unread,
Nov 11, 2017, 3:29:22 AM11/11/17
to meetecho-janus
One way to force TURN candidate gathering in Safari is by setting iceTransportPolicy to 'relay'.  I think you can put it under `iceServers`.  To work with all browsers, do something like:

    // If browser is Safari, force TURN relay candidates.  Otherwise use all ICE candidates
    iceTransportPolicy: browser === 'safari' ? 'relay' : 'all'

And as Lorenzo mentions, we are using the TURN configuration set up in the Javascript, not in Janus.

Lorenzo Miniero

unread,
Nov 11, 2017, 4:20:46 AM11/11/17
to meetecho-janus
With janus.js, you can specify it when creating the session:


L.

yarek chmielewski

unread,
Nov 11, 2017, 2:59:34 PM11/11/17
to meetecho-janus
Hi: 
THAT WORKED !

So if someone wants to BYPASS that horrible Safari [bug|limitation|protection] stuff (you cannot stream without publishing), you can bypass that forcing TURN server like Slack did: 

Maybe you should put that in FAQ because I am pretty sure many developers will ask for that soon.

So for safari: 
- use H264 codec (in videoroom chat config), do not use VP8
- Force Turn: 

in janus.js

//var pc_config = {"iceServers": iceServers, "iceTransportPolicy": iceTransportPolicy};
var pc_config = {"iceServers": iceServers, iceTransportPolicy: browser === 'safari' ? 'relay' : 'all'};


In your own JS : use that: 

server: server,
iceServers :[{url: 'turn:numb.viagenie.ca', // or use coturn
credential: '***',
username: 'yarek'
}],

regards

yarek chmielewski

unread,
Nov 11, 2017, 4:50:40 PM11/11/17
to meetecho-janus
I was too optimistic. I could not force it

I used that in my JS: 
janus = new Janus({
server: server,
iceServers :[{url: 'turn:numb.viagenie.ca',
        credential: '***',
username: 'yarek'
}],


and changed that in janus.js
var pc_config = {"iceServers": iceServers, "iceTransportPolicy": 'relay'};

And.. I cannot watch any stream any more...



Lorenzo Miniero

unread,
Nov 11, 2017, 8:57:11 PM11/11/17
to meetecho-janus
Don't change janus.js, we expose a way to specify it in the library so just pass the iceTransportPolicy when creating the session object instead. Changing the JavaScript means you may be hitting a cached value. Not sure if Safari has any developer tool for WebRTC, but you may want to check if relay candidates are being gathered by the browser: you can check this via Admin API in Janus too.

L.
Reply all
Reply to author
Forward
0 new messages