-
Notifications
You must be signed in to change notification settings - Fork 731
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
create fallback turn server option #4391
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
Please see my first remarks.
Also can you add a file for the changelog as per https://github.com/vector-im/element-android/blob/main/CONTRIBUTING.md#changelog ?
Thanks
@@ -269,17 +271,28 @@ class WebRtcCall( | |||
private fun createPeerConnection(turnServerResponse: TurnServerResponse?) { | |||
val peerConnectionFactory = peerConnectionFactoryProvider.get() ?: return | |||
val iceServers = mutableListOf<PeerConnection.IceServer>().apply { | |||
turnServerResponse?.let { server -> | |||
server.uris?.forEach { uri -> | |||
if (vectorPreferences.useFallbackTurnServer()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a specialist on this part of the code, but maybe use the fallback if and only if `turnServerResponse?.uris is null or empty, and the user has enable the fallback from the setting?
vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt
Outdated
Show resolved
Hide resolved
Thank you for reviewing this! I actually don't know if this change fixes #2329 at all, I've asked people there to test out my builds. I'll finish up work on this PR if I get positive feedback on the changes. |
Ok, thanks. I have enabled the CI for this PR so that APKs will be built and can be downloaded from here to be tested. |
Thank you! |
Nice PR @CicadaCinema but I prefer to use the TURN first from Homeserver instead of general Matrix to use.... I think, you can read this from API or you switch the Server URLs to gradle vars to find and setup faster the own TURN Server like me.... But anyway good work 👍🏻 |
Thank you! If this setting is enabled, I plan to only use turn.matrix.org when the user's homeserver does not have one that they can use (similarly to the way the setting in Element Web works). |
awesome change! with the fallback only being used when no turn server uris are returned by the server and the preference is enabled this looks like it ticks everyone's boxes |
server.uris?.forEach { uri -> | ||
val useFallback = server.uris.isNullOrEmpty() && vectorPreferences.useFallbackTurnServer() | ||
val serverList = if (useFallback) stringArrayProvider.getStringArray(R.array.fallback_ice_servers).toList() else server.uris | ||
serverList?.forEach { uri -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a stupid question, but do we want to use the fallback if turnServerResponse
is null? Here this will not be the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we should only use the fallback if the home server does not define any ice servers (consitent with web).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so the code turnServerResponse?.let { server ->
has to be updated IIUC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there, I've handled that now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one question, but not blocking the merging
Notice that using a fallback while revealing your IP to the relay will also hide it to your contact. |
Also the old android app was prompting the user to enable this option when you have a call that failed to connect and that your home server had no ice server config. Maybe a nice to have feature |
add( | ||
PeerConnection | ||
.IceServer | ||
.builder(uri) | ||
.setUsername(server.username) | ||
.setPassword(server.password) | ||
.setUsername(if (useFallback) "xxxxx" else server.username) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback is stun, should do (from old sdk)
if (!defaultIceServerUri.startsWith("stun:")) {
defaultIceServerUri = "stun:" + defaultIceServerUri;
}
defaultIceServer = PeerConnection.IceServer.builder(defaultIceServerUri).createIceServer();
@@ -7,6 +7,12 @@ | |||
<string name="matrix_org_server_url" translatable="false">https://matrix.org</string> | |||
<string name="piwik_server_url" translatable="false">https://piwik.riot.im</string> | |||
<string name="bug_report_url" translatable="false">https://riot.im/bugreports/submit</string> | |||
<string name="fallback_stun_server_url" translatable="false">turn.matrix.org</string> | |||
<string-array name="fallback_ice_servers" translatable="false"> | |||
<item>turn:turn.matrix.org:3478?transport=udp</item> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work, turn.matrix.org requires auth.
Just use stun: would work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fallback_ice_servers
can just be removed now I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I've removed it
@@ -724,7 +724,7 @@ | |||
<!-- Note to translators: the translation MUST contain the string "${app_name}", which will be replaced by the application name --> | |||
<string name="template_settings_call_ringtone_use_app_ringtone">Use default ${app_name} ringtone for incoming calls</string> | |||
<string name="settings_call_ringtone_use_default_stun">Allow fallback call assist server</string> | |||
<string name="settings_call_ringtone_use_default_stun_sum">Will use "%s" as assist when your homeserver does not offer one (your IP address will be shared during a call)</string> | |||
<string name="settings_call_ringtone_use_default_stun_sum">Will use %s as assist when your homeserver does not offer one (your IP address will be shared during a call)</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this copy is missleading. IP will be shared with who? the peer yes, the stun yes.
Not using it will still share your IP with the peer.
So maybe your IP will be seen by the stun server? (not sure how valuable/actionable this information is for the user, given that not doing it will make calls fails depending on your network)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
The default server will only do stun, please see my comments.
also clarify option description, and mark old string to be removed
I adjusted the behaviour of the fallback to use the stun server instead, and I adjusted the option description.
I'm not sure how to even begin implementing this unfortunately - I only took a look at this issue because I noticed I couldn't make calls myself. |
PR Moved to #5781 |
PR Moved to #5781
Fixes #2329
Fixes #3063
You need to enable the fallback option in
Settings > Voice & Video
to use this feature:Pull Request Checklist