Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TURN support #30

Merged
merged 3 commits into from
Nov 12, 2020
Merged

Add TURN support #30

merged 3 commits into from
Nov 12, 2020

Conversation

farao
Copy link
Member

@farao farao commented Jun 20, 2020

The client receives a turn login on room join if the server supports TURN.
It first tries a connection via stun. If that fails, it tries again with
turn using the received login.

@farao
Copy link
Member Author

farao commented Jun 20, 2020

Needs testing together with palavatv/palava-web#59 and palavatv/signaltower#30.

username: @room.options.turn.username
credential: @room.options.turn.password
urls: [@room.options.turn]
username: @turnCredentials.user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for completely removing static configuration!

@@ -29,6 +29,7 @@ class palava.RemotePeer extends palava.Peer
@setupPeerConnection(offers)
@setupDistributor()

@offers = offers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #20 yields that we have to keep this around, we should really rename this flag

#
# @return [Object] true if turn was tried by using the tryTurn function
#
tryTurn: (credentials) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for the idea to only use TURN when the peer connection has failed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't see the value of this in the way it's currently implemented. The browser chooses the ice candidate pair based on the "cost" of the connection with TURN being lowest priority. The only drawback are the minimal resources used for reserving a TURN connection which does not get used (if the browser even gets to that).

Would be another scenario if the credentials were requested/created when the connection fails. But with the credentials being present from the start I don't see the point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it wasn't always like that right? I can at least remember times when a TURN server was given, it was always turn being used. Is this choosing the lowest cost ice candidate pair documented somewhere or is that your experience and did you try that with all major browsers?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The process is described in the ICE RFC section about prioritizing candiates,. You can see the priorities in the SDP of the candidates.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I changed it back to directly adding turn to the connection

@@ -29,6 +29,7 @@ class palava.Session extends @EventEmitter

@createChannel()
@createRoom()
@createTurnAPIClient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'll remove it (the other case as well)

@@ -177,6 +184,9 @@ class palava.Session extends @EventEmitter
@room.on 'signaling_error', (t, e) => @emit 'signaling_error', t, e
true

createTurnAPIClient: =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still needed?

@@ -52,11 +53,11 @@ class palava.RemotePeer extends palava.Peer
options = []
if @room.options.stun
options.push({urls: [@room.options.stun]})
if @room.options.turn
if @room.options.turn && @turnCredentials
options.push
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only being able to add one TURN configuration is limiting. A common scenario is adding one TURN server using UDP and one server using TCP (with and/or without TLS). Physically this can be the same TURN server, just a different configuration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I changed that in the latest commit

The client receives a turn login on room join if the server supports TURN.
It first tries a connection via stun. If that fails, it tries again with
turn using the received login.
@farao farao force-pushed the turn branch 2 times, most recently from 3e0fae6 to 37c3191 Compare July 23, 2020 10:10
@farao farao requested a review from janlelis November 9, 2020 22:13
@janlelis janlelis merged commit 1552b4a into master Nov 12, 2020
@janlelis janlelis deleted the turn branch November 12, 2020 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants