Nheko-Reborn / nheko

Desktop client for Matrix using Qt and C++20.
https://nheko-reborn.github.io/
GNU General Public License v3.0
1.95k stars 201 forks source link

Nheko appears to force TURN server usage. #491

Open sergstesh opened 3 years ago

sergstesh commented 3 years ago

I am running the client in my Kubuntu-18.04 this way:

flatpak --verbose run io.github.NhekoReborn.Nheko &

Looking into screen output among other things I see:

[2021-02-23 18:21:50.709] [net] [info] TURN server(s) retrieved from homeserver:
...
[2021-02-23 18:21:50.709] [net] [info] uri: turn:turn.matrix.org:3478?transport=udp
[2021-02-23 18:21:50.709] [net] [info] uri: turn:turn.matrix.org:3478?transport=tcp
[2021-02-23 18:21:50.709] [net] [info] uri: turns:turn.matrix.org:443?transport=tcp
...
[2021-02-23 18:22:01.151] [ui] [info] WebRTC: setting TURN server: turn://1614183738%3A%40sergstesh%3Amatrix.org:JaaIIFMhnMDMwF8XGXunP4Ol%2BCg%3D@turn.matrix.org:3478?transport=udp
[2021-02-23 18:22:01.151] [ui] [info] WebRTC: setting TURN server: turn://1614183738%3A%40sergstesh%3Amatrix.org:JaaIIFMhnMDMwF8XGXunP4Ol%2BCg%3D@turn.matrix.org:3478?transport=tcp
[2021-02-23 18:22:01.151] [ui] [info] WebRTC: setting TURN server: turns://1614183738%3A%40sergstesh%3Amatrix.org:JaaIIFMhnMDMwF8XGXunP4Ol%2BCg%3D@turn.matrix.org:443?transport=tcp
...
[2021-02-23 18:23:08.089] [ui] [info] WebRTC: setting TURN server: turn://1614183738%3A%40sergstesh%3Amatrix.org:JaaIIFMhnMDMwF8XGXunP4Ol%2BCg%3D@turn.matrix.org:3478?transport=udp
[2021-02-23 18:23:08.090] [ui] [info] WebRTC: setting TURN server: turn://1614183738%3A%40sergstesh%3Amatrix.org:JaaIIFMhnMDMwF8XGXunP4Ol%2BCg%3D@turn.matrix.org:3478?transport=tcp
[2021-02-23 18:23:08.090] [ui] [info] WebRTC: setting TURN server: turns://1614183738%3A%40sergstesh%3Amatrix.org:JaaIIFMhnMDMwF8XGXunP4Ol%2BCg%3D@turn.matrix.org:443?transport=tcp

.

In 'element-desktop' client there is explicit option in settings menu to avoid using TURN server. I didn't find this option in Nheko settings - maybe I missed it.

I would like the default to be using STUN server, and as in 'element-desktop' usage of TURN server as fallback should be an option.

trilene commented 3 years ago

Despite its name, turn.matrix.org offers STUN only. It's a free service that's only relevant if you haven't set up your own TURN server. This is the fallback option that Element refers to. The same fallback option also exists in Nheko's settings.

sergstesh commented 3 years ago

The same fallback option also exists in Nheko's settings

OK, I have finally found it. Unfortunately Nheko starts with Russian interface (most likey a KDE bug), and even though I am a native Russian speaker it takes effort to recognize familiar English terms translated into Russian. In this case it's "Разрешить помощь резервного сервера для звонков".

Is there a way to force English as the interface language ?

trilene commented 3 years ago

Think you just need to set the LANGUAGE env var. From the command line:

$ LANGUAGE=en nheko

sergstesh commented 3 years ago

Think you just need to set the LANGUAGE env var. From the command line:

$ LANGUAGE=en nheko

Thanks, the language issue is resolved - also with flatpak:

(LANGUAGE=en flatpak --verbose run io.github.NhekoReborn.Nheko) & .

deepbluev7 commented 3 years ago

So is this still an issue then or not? :D

sergstesh commented 3 years ago

So is this still an issue then or not? :D

This is not an issue, you can close it. Thanks to all for replies.

I'll most likely open another issue regarding STUN/TURN servers. I think user should have a possibility to provide STUN/TURN server name or IP address and port number. This is because at the moment STUN/TURN server is single point of failure.

Matrix infrastructure/spec do not rely on matrix.org and friends, so user should be able to detach completely from the matrix organization servers if he desires so. At the moment user can configure and run his own homeserver, so clients should have possibility to use STUN/TURN servers not related to the matrix organization.

trilene commented 3 years ago

You specify your TURN server details in your homeserver configuration. These are read and used by Nheko as per the Matrix spec.

sergstesh commented 3 years ago

You specify your TURN server details in your homeserver configuration. These are read and used by Nheko as per the Matrix spec.

Does it mean that the spec does not stipulate overriding TURN server in client ?

trilene commented 3 years ago

It doesn't last time I checked and I'm not aware that even Element allows that.

sergstesh commented 3 years ago

I didn't mean to file an issue only against Nheko, I meant to file it also against element and friends.

Anyway, we have kinda conceptual problem. According to my very limited knowledge of Matrix the canonical p2p communications happen this way:

client_1 <===> homeserver_1 <===> homeserver_2 <===> client_2 . homeserver_1 and homeserver_2 may have different specifications for STUN/TURN servers. And for p2p communications to occur there should one/same STUN/TURN server for a given session.

So, whose configuration WRT to STUN/TURN server does each client read ? Own or other ?

Or is it that the side initiating communications reads, say own homeserver configuration and somehow passes to the other side data on STUN/TURN server ?

...

Can it be we have a spec issue ?

deepbluev7 commented 3 years ago

From my understanding, each user auths against their turn server configured in their home server. Those are then added to the connection candidates. Whatever works is then picked, which is somewhat random. So it could be using the turn server of homeserver_1 and homeserver_2.

I think the spec issue, is that currently you can only have one turn server per homeserver. It may be nice to provide multiple there. One could also replace the turnserver with a different proxy, that allows also efficient conferences, but that is a bigger issue and not something Nheko can tackle alone. :D

I think this is an issue, that people on the spec team are aware of, but that may take a while to get somewhere.

deepbluev7 commented 3 years ago

Also a client can't just override the turn server, since the current turnservers require you to have a matrix account on your HS to authenticate. So adding client side overrides may be more difficult than just adding an additional url. In all cases it is probably better to fix your server configuration in that case, there is even a tool that you can use to test your setup: https://test.voip.librepush.net/