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

Always install a local TURN server and share port 443 #579

Merged
merged 15 commits into from
Jan 24, 2023

Conversation

schrd
Copy link
Contributor

@schrd schrd commented Dec 1, 2022

This patch changes the current BBB 2.6 setup in the following way:

  • install coturn on all machines
  • install haproxy and let it serve port 443
  • configure nginx to use port 127.0.0.1:81 without encryption
  • configure BBB to use the local coturn using the turns protocol

haproxy will terminate the TLS connection and use the first byte to decide if the traffic will go to nginx or coturn.

Daniel Schreiber added 2 commits December 1, 2022 18:41
This patch changes the current setup in the following way:

* install coturn on all machines
* install haproxy and let it serve port 443
* configure nginx to use port 127.0.0.1:81 without encryption
* configure BBB to use the local coturn using the `turns` protocol

haproxy will terminate the TLS connection and use the first byte to decide
if the traffic will go to nginx or coturn.
HTTP2 is a binary protocol. So switching on the first byte does not
work. If the client wants to speak HTTP2, it will negotiate this by ALPN
in the TLS handshake. haproxy can use this to send traffic in the right
direction.

As of section 3.1 in RFC 7540 using APLN to negotiate on HTTP2 is
mandatory for encrypted connections.
@ffdixon
Copy link
Member

ffdixon commented Dec 6, 2022

Nice! Will test and let you know how it works.

bbb-install-2.6.sh Outdated Show resolved Hide resolved
bbb-install-2.6.sh Outdated Show resolved Hide resolved
@EmmyGraugans
Copy link

And a last comment (for now) to get this to work is the redirect of greenlight:

if [ ! -f /usr/share/bigbluebutton/nginx/greenlight.nginx ]; then
docker run --rm bigbluebutton/greenlight:v2 cat ./greenlight.nginx | tee /usr/share/bigbluebutton/nginx/greenlight.nginx
cat > /usr/share/bigbluebutton/nginx/greenlight-redirect.nginx << HERE
location = / {
return 307 /b/;

This needs to be changed/added to

  if [ ! -f /usr/share/bigbluebutton/nginx/greenlight.nginx ]; then
    docker run --rm bigbluebutton/greenlight:v2 cat ./greenlight.nginx | tee /usr/share/bigbluebutton/nginx/greenlight.nginx
    sed -i '/X-Forwarded-Proto/s/$scheme/"https"/' /usr/share/bigbluebutton/nginx/greenlight.nginx
    cat > /usr/share/bigbluebutton/nginx/greenlight-redirect.nginx << HERE
location = / {
  return 307 https://$server_name/b/;

Reasoning:

  • the X-Forwarded-Proto must be set explicitly to https, because $proto will show "http", because of the redirect on localhost, but the client can only ever see https, because everything else will be redirected already before
  • the return 307 needs an explicit https://$server_name, because otherwise we would get redirects to Port 82 or 81 (which are open only on localhost), depending on http/2 or http/1

thanks @EmmyGraugans for feedback
Daniel Schreiber added 2 commits December 12, 2022 16:07
TURN connections should be offered on two transports to the client:

* port 443 TCP (thats what haproxy redirects to coturn)
* port 3478 UDP

The UDP port likely offers better quality for clients than the TCP
connections as TCP connections stall when packets are lost. So UDP
connections should be always preferred over TCP connections for WebRTC
connections as long as udp is not blocked by firewalls. Firefox needs to
relay all its traffic that goes to mediasoup through a turn server as a
workaround for their broken ICE implementation.

With fullaudio which lets mediasoup proxy audio connections to
freeswitch this is becoming even more important for a good out of the
box experience.
This is part of the operator config and it belongs to /etc according to
FHS.
mode tcp
server localhost 127.0.0.1:82
END
chown root:haproxy "$HAPROXY_CFG"
Copy link
Member

Choose a reason for hiding this comment

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

In testing we need to add

cat /etc/letsencrypt/live/$HOST/{fullchain,privkey}.pem > /etc/haproxy/certbundle.pem

to create /etc/haproxy/certbundle.pem

Daniel Schreiber added 3 commits December 14, 2022 00:10
haproxy could not use the certificate because it wasn't there yet
@BrentBaccala
Copy link
Contributor

At some point we need to fix bbb-conf to present the nginx port numbers better.

Currently I'm getting output like this:

/etc/nginx/sites-available/bigbluebutton (nginx)
                       server_name: focal-260.samsung
                              port: 80, [::]:80127.0.0.1:82 http2, [::1]:82 http2127.0.0.1:81, [::1]:81

It's just a parsing issue, and we have larger nuts to crack, but I just wanted to note it.

@BrentBaccala
Copy link
Contributor

I'm testing using Firefox on a GNS3 test network.

This is what I'm seeing in haproxy.log when I create a meeting, join as moderator, try to connect with the microphone (I get an ICE 1007 after a timeout), then end the meeting:

Dec 20 00:43:22 focal-260 haproxy[52844]: 128.8.8.5:49762 [20/Dec/2022:00:43:22.817] nginx_or_turn~ nginx/localhost 62/0/87 42414 -- 3/3/1/1/0 0/0 captured_user:G
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49784 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49838 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49882 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49852 [20/Dec/2022:00:43:28.857] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49800 [20/Dec/2022:00:43:28.857] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49894 [20/Dec/2022:00:43:28.858] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49922 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49808 [20/Dec/2022:00:43:28.872] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49932 [20/Dec/2022:00:43:28.862] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49864 [20/Dec/2022:00:43:28.872] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49774 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49822 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49880 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49914 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50010 [20/Dec/2022:00:43:28.951] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49956 [20/Dec/2022:00:43:28.951] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49906 [20/Dec/2022:00:43:28.872] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49948 [20/Dec/2022:00:43:28.933] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50058 [20/Dec/2022:00:43:29.000] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49996 [20/Dec/2022:00:43:28.933] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50056 [20/Dec/2022:00:43:29.025] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49984 [20/Dec/2022:00:43:28.918] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50028 [20/Dec/2022:00:43:28.996] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50042 [20/Dec/2022:00:43:28.996] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50046 [20/Dec/2022:00:43:28.996] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50070 [20/Dec/2022:00:43:28.997] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49970 [20/Dec/2022:00:43:28.912] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50014 [20/Dec/2022:00:43:28.930] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50022 [20/Dec/2022:00:43:28.930] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50086 [20/Dec/2022:00:43:28.997] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:57 focal-260 haproxy[52844]: 192.168.8.1:40020 [20/Dec/2022:00:43:40.879] nginx_or_turn~ nginx/localhost 9/0/16364 2446 -- 4/4/2/2/0 0/0 captured_user:G
Dec 20 00:44:05 focal-260 haproxy[52844]: 192.168.8.1:41250 [20/Dec/2022:00:43:28.712] nginx_or_turn~ nginx/localhost 9/0/36951 12541 -- 3/3/1/1/0 0/0 captured_user:G
Dec 20 00:44:12 focal-260 haproxy[52844]: 128.8.8.5:49754 [20/Dec/2022:00:43:22.722] nginx_or_turn~ nginx/localhost 18/0/50020 42414 cD 2/2/0/0/0 0/0 captured_user:G

The flurry of SSL handshake errors comes after the create (using API Mate), but before the join, with about a five second pause between the successful API call and the log messages. There's no HTML5 client connected at that point. I'm just learning haproxy, but the way I read these logs files is that none of the connections is being relayed to the turn server, and that is consistent with turnserver.log (it's pretty much empty).

All I have to do to get it working, though, is to switch turn-stun-servers.xml in /etc/bigbluebutton to point to a TURN server installed the old way, so it seems like the problem is probably isolated to the haproxy setup.

I'm packing it in for today. @schrd, in particular, I welcome any suggestions on how to debug this further.

@mohamedrelsayed2811
Copy link

I'm testing using Firefox on a GNS3 test network.

This is what I'm seeing in haproxy.log when I create a meeting, join as moderator, try to connect with the microphone (I get an ICE 1007 after a timeout), then end the meeting:

Dec 20 00:43:22 focal-260 haproxy[52844]: 128.8.8.5:49762 [20/Dec/2022:00:43:22.817] nginx_or_turn~ nginx/localhost 62/0/87 42414 -- 3/3/1/1/0 0/0 captured_user:G
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49784 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49838 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49882 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49852 [20/Dec/2022:00:43:28.857] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49800 [20/Dec/2022:00:43:28.857] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49894 [20/Dec/2022:00:43:28.858] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49922 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49808 [20/Dec/2022:00:43:28.872] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49932 [20/Dec/2022:00:43:28.862] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49864 [20/Dec/2022:00:43:28.872] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49774 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49822 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49880 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49914 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50010 [20/Dec/2022:00:43:28.951] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49956 [20/Dec/2022:00:43:28.951] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49906 [20/Dec/2022:00:43:28.872] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49948 [20/Dec/2022:00:43:28.933] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50058 [20/Dec/2022:00:43:29.000] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49996 [20/Dec/2022:00:43:28.933] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50056 [20/Dec/2022:00:43:29.025] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49984 [20/Dec/2022:00:43:28.918] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50028 [20/Dec/2022:00:43:28.996] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50042 [20/Dec/2022:00:43:28.996] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50046 [20/Dec/2022:00:43:28.996] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50070 [20/Dec/2022:00:43:28.997] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49970 [20/Dec/2022:00:43:28.912] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50014 [20/Dec/2022:00:43:28.930] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50022 [20/Dec/2022:00:43:28.930] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50086 [20/Dec/2022:00:43:28.997] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:57 focal-260 haproxy[52844]: 192.168.8.1:40020 [20/Dec/2022:00:43:40.879] nginx_or_turn~ nginx/localhost 9/0/16364 2446 -- 4/4/2/2/0 0/0 captured_user:G
Dec 20 00:44:05 focal-260 haproxy[52844]: 192.168.8.1:41250 [20/Dec/2022:00:43:28.712] nginx_or_turn~ nginx/localhost 9/0/36951 12541 -- 3/3/1/1/0 0/0 captured_user:G
Dec 20 00:44:12 focal-260 haproxy[52844]: 128.8.8.5:49754 [20/Dec/2022:00:43:22.722] nginx_or_turn~ nginx/localhost 18/0/50020 42414 cD 2/2/0/0/0 0/0 captured_user:G

The flurry of SSL handshake errors comes after the create (using API Mate), but before the join, with about a five second pause between the successful API call and the log messages. There's no HTML5 client connected at that point. I'm just learning haproxy, but the way I read these logs files is that none of the connections is being relayed to the turn server, and that is consistent with turnserver.log (it's pretty much empty).

All I have to do to get it working, though, is to switch turn-stun-servers.xml in /etc/bigbluebutton to point to a TURN server installed the old way, so it seems like the problem is probably isolated to the haproxy setup.

I'm packing it in for today. @schrd, in particular, I welcome any suggestions on how to debug this further.

I have the same error 1007 ICE when try to connect with audio (webcam and sharescreen work perfect)
i'm use firefox (not use any other turn server)

my server in amazon ec2

@schrd
Copy link
Contributor Author

schrd commented Dec 20, 2022

I'm testing using Firefox on a GNS3 test network.

This is what I'm seeing in haproxy.log when I create a meeting, join as moderator, try to connect with the microphone (I get an ICE 1007 after a timeout), then end the meeting:

Dec 20 00:43:22 focal-260 haproxy[52844]: 128.8.8.5:49762 [20/Dec/2022:00:43:22.817] nginx_or_turn~ nginx/localhost 62/0/87 42414 -- 3/3/1/1/0 0/0 captured_user:G
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49784 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure

...

I'm packing it in for today. @schrd, in particular, I welcome any suggestions on how to debug this further.

I'd probably start using tcpdump or termshark. Are you sure that the turn configuration uses turns and not turn as protocol? turns is required because haproxy expects encrypted traffic.

@BrentBaccala
Copy link
Contributor

@schrd, I'm pretty sure it's using turns. I used your bbb-install-2.6.sh script without changing a thing, and its XML points turns at port 443 and turn at port 3478, which all seems correct.

I'm looking at this line in haproxy.conf:

  bind *:443 ssl crt /etc/haproxy/certbundle.pem ssl-min-ver TLSv1.2 alpn h2,http/1.1

Is the end of this advising the client that it should select either 'h2' or 'http/1.1' as its ALPN choices? If so, wouldn't a compliant client never select TURN? I'm asking, since I'm just learning haproxy!

In any event, I can confirm that I'm seeing failures with both Firefox and Chromium, and am continuing to investigate.

@mohamedrelsayed2811
Copy link

I'm testing using Firefox on a GNS3 test network.
This is what I'm seeing in haproxy.log when I create a meeting, join as moderator, try to connect with the microphone (I get an ICE 1007 after a timeout), then end the meeting:

Dec 20 00:43:22 focal-260 haproxy[52844]: 128.8.8.5:49762 [20/Dec/2022:00:43:22.817] nginx_or_turn~ nginx/localhost 62/0/87 42414 -- 3/3/1/1/0 0/0 captured_user:G
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49784 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure

...

I'm packing it in for today. @schrd, in particular, I welcome any suggestions on how to debug this further.

I'd probably start using tcpdump or termshark. Are you sure that the turn configuration uses turns and not turn as protocol? turns is required because haproxy expects encrypted traffic.

yes it's works now i was missing something

thank you

it's works now very good

and i send the output of the WebRTC i hope you see it to let me if something wrong
image

image

@BrentBaccala
Copy link
Contributor

yes it's works now i was missing something

thank you

it's works now very good

and i send the output of the WebRTC i hope you see it to let me if something wrong image

The DNS names in that image start with "turn". That suggests to me the older setup with a separate TURN server.

Any idea what you did to get this working?

@schrd
Copy link
Contributor Author

schrd commented Dec 20, 2022

@schrd, I'm pretty sure it's using turns. I used your bbb-install-2.6.sh script without changing a thing, and its XML points turns at port 443 and turn at port 3478, which all seems correct.

I'm looking at this line in haproxy.conf:

  bind *:443 ssl crt /etc/haproxy/certbundle.pem ssl-min-ver TLSv1.2 alpn h2,http/1.1

Is the end of this advising the client that it should select either 'h2' or 'http/1.1' as its ALPN choices? If so, wouldn't a compliant client never select TURN? I'm asking, since I'm just learning haproxy!

ALPN is a mechanism to negotiate protocols during the TLS handshake before any inner payload data is exchanged. This statement means that haproxy should signal to the client that it supports h2 and http/1.1 protocols. ALPN is not required to establish a TLS connection. The logic in this haproxy configuration works like this:

  1. check the negotiated ALPN protocol. If there is a negotiated protocol (h2, http/1.1) redirect traffic to Port 81 or 82
  2. if no protocol has been negotiated, inspect the first by of the traffic. If it starts with a character redirect traffic to nginx
  3. else redirect traffic to coturn

In any event, I can confirm that I'm seeing failures with both Firefox and Chromium, and am continuing to investigate.

You said you have these failed requests the create and join API calls. I doubt that browsers will try to establish either a turn connection before the html5 client is loaded. What frontend do you use to create/join sessions? Is there any monitoring tool or load balancer etc polling the API in between? Does the request come from the client IP? I am curious what could be causing this. I'd really like to debug this interactively with you and see what is going on. Drop me a mail if you like.

@kepstin
Copy link
Contributor

kepstin commented Dec 20, 2022

For reference, you should know that STUN/TURN also has an ALPN label: stun.turn, and from my earlier testing, I think this label is used by web browsers when making turns: connections.

When I was testing before, I think I ended not requiring any traffic inspection (decryption in haproxy) at all, the ALPN was sufficient.

@mohamedrelsayed2811
Copy link

I'm testing using Firefox on a GNS3 test network.

This is what I'm seeing in haproxy.log when I create a meeting, join as moderator, try to connect with the microphone (I get an ICE 1007 after a timeout), then end the meeting:

Dec 20 00:43:22 focal-260 haproxy[52844]: 128.8.8.5:49762 [20/Dec/2022:00:43:22.817] nginx_or_turn~ nginx/localhost 62/0/87 42414 -- 3/3/1/1/0 0/0 captured_user:G
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49784 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49838 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49882 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49852 [20/Dec/2022:00:43:28.857] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49800 [20/Dec/2022:00:43:28.857] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49894 [20/Dec/2022:00:43:28.858] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49922 [20/Dec/2022:00:43:28.859] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49808 [20/Dec/2022:00:43:28.872] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49932 [20/Dec/2022:00:43:28.862] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49864 [20/Dec/2022:00:43:28.872] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49774 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:28 focal-260 haproxy[52844]: 128.8.8.5:49822 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49880 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49914 [20/Dec/2022:00:43:28.868] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50010 [20/Dec/2022:00:43:28.951] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49956 [20/Dec/2022:00:43:28.951] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49906 [20/Dec/2022:00:43:28.872] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49948 [20/Dec/2022:00:43:28.933] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50058 [20/Dec/2022:00:43:29.000] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49996 [20/Dec/2022:00:43:28.933] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50056 [20/Dec/2022:00:43:29.025] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49984 [20/Dec/2022:00:43:28.918] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50028 [20/Dec/2022:00:43:28.996] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50042 [20/Dec/2022:00:43:28.996] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50046 [20/Dec/2022:00:43:28.996] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50070 [20/Dec/2022:00:43:28.997] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:49970 [20/Dec/2022:00:43:28.912] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50014 [20/Dec/2022:00:43:28.930] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50022 [20/Dec/2022:00:43:28.930] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:29 focal-260 haproxy[52844]: 128.8.8.5:50086 [20/Dec/2022:00:43:28.997] nginx_or_turn/1: SSL handshake failure
Dec 20 00:43:57 focal-260 haproxy[52844]: 192.168.8.1:40020 [20/Dec/2022:00:43:40.879] nginx_or_turn~ nginx/localhost 9/0/16364 2446 -- 4/4/2/2/0 0/0 captured_user:G
Dec 20 00:44:05 focal-260 haproxy[52844]: 192.168.8.1:41250 [20/Dec/2022:00:43:28.712] nginx_or_turn~ nginx/localhost 9/0/36951 12541 -- 3/3/1/1/0 0/0 captured_user:G
Dec 20 00:44:12 focal-260 haproxy[52844]: 128.8.8.5:49754 [20/Dec/2022:00:43:22.722] nginx_or_turn~ nginx/localhost 18/0/50020 42414 cD 2/2/0/0/0 0/0 captured_user:G

The flurry of SSL handshake errors comes after the create (using API Mate), but before the join, with about a five second pause between the successful API call and the log messages. There's no HTML5 client connected at that point. I'm just learning haproxy, but the way I read these logs files is that none of the connections is being relayed to the turn server, and that is consistent with turnserver.log (it's pretty much empty).

All I have to do to get it working, though, is to switch turn-stun-servers.xml in /etc/bigbluebutton to point to a TURN server installed the old way, so it seems like the problem is probably isolated to the haproxy setup.

I'm packing it in for today. @schrd, in particular, I welcome any suggestions on how to debug this further.

any luck to solve this error?

I'm installed the script in a fresh server and have the same errors

@ffdixon
Copy link
Member

ffdixon commented Dec 25, 2022

An update on my end.

I'm testing the local TURN server on Amazon EC2. EC2 instances have the public/private IP address. I needed to change the configuration of the TURN server to define and external IP address.

#listening-ip=35.182.24.35
#relay-ip=35.182.24.35

listening-ip=172.31.44.244
relay-ip=172.31.44.244
external-ip=35.182.24.35/172.31.44.244

I also commented out

# we only need to allow peer connections from the machine itself (from mediasoup or freeswitch).
#denied-peer-ip=0.0.0.0-255.255.255.255
#denied-peer-ip=::-ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
#$allowed-peer-ip=35.182.24.35
#llowed-peer-ip=172.31.44.244

So I could test use the TURN server stand-alone with another BigBlueButton server and make sure it was working. I tested with FireFox where I can force it to use a TURN server by setting media.peerconnection.ice.relay_only to true in about:config.

When accessing BigBlueButton + TURN server configuration, sharing of video with FireFox works, but not FreeSWITCH (I'm not using fullaudio). I check the logs and I can see that FreeSWITCH FreeSWITCH receives the call, but at some point it switches to use the internal IP address

2022-12-25 19:27:52.870256 99.17% [NOTICE] switch_rtp.c:1314 Auto Changing audio stun/rtp/dtls port from 35.182.24.35:65231 to 172.31.44.244:65231 idx:-1

After that the FreeSWITCH log pauses, and then a few seconds later the BigBlueButton client gives a 1010 error.

Interested if anyone else could get further with running a local TURN server on an EC2 instance.

Daniel Schreiber added 3 commits December 26, 2022 21:27
With proxy_protocol support the original IP from the client will appear
in nginx log instead of 127.0.0.1 for all requests
@schrd
Copy link
Contributor Author

schrd commented Dec 26, 2022

Added some fixes suggested by @BrentBaccala and Christoph Martin. These include:

  • fixes for BBB behind NAT
  • use proxy_protocol for communication between haproxy and nginx -- so that nginx logs the originating request IP instead of 127.0.0.1

I did not yet test on dual stack setups, these may need more tweaks.

@mohamedrelsayed2811
Copy link

mohamedrelsayed2811 commented Dec 26, 2022

Hello,

i'm figured out 4 way to fix problem error 1010 or 1007 in ec2 or aws lightsail

i'm tested the 4 way and it's works well

1- For fresh install (before install script just check opened port and just open port 80 and port 22(ssh) ) after install script just open port 443/tcp, 3478/tcp , 16384-65535/udp
then try to open meeting if not works restart the instance

2- if you already installed script change the value of server localhost in the haproxy.cfg :

backend turn mode tcp server localhost private_ip:3478

and check turnserver.conf and make sure to change valuse like example below:

`listening-port=3478

listening-ip=private-ip
relay-ip=public-ip

external-ip=public-ip/private-ip

min-port=32769
max-port=65535
verbose

fingerprint
lt-cred-mech
use-auth-secret
static-auth-secret=secret
realm=domain

keep-address-family

no-cli
no-tlsv1
no-tlsv1_1

allowed-peer-ip=private-ip
allowed-peer-ip=public-ip

`

then: restart haproxy and turnserve
service haproxy reload
sudo systemctl restart coturn

then it will work

3- check the value for haproxy.cfg:
backend turn mode tcp server localhost public-ip:3478

and turnserver config

listening-port=3478

listening-ip=public-ip/private-ip
relay-ip=public-ip/private-ip

external-ip=public-ip/private-ip

min-port=32769
max-port=65535
verbose

fingerprint
lt-cred-mech
use-auth-secret
static-auth-secret=secret_value
realm=domain-name

keep-address-family

no-cli
no-tlsv1
no-tlsv1_1

no-loopback-peers
no-multicast-peers

denied-peer-ip=0.0.0.0-255.255.255.255
denied-peer-ip=::-ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
allowed-peer-ip=private-ip
allowed-peer-ip=public-ip
allowed-peer-ip=public-ip/private-ip

then: restart haproxy and turnserve
service haproxy reload
sudo systemctl restart coturn

4- i'm not sure it's right or not but we will make freeswitch and kurento to listen only to private-ip in (local, external)

I hope this will help

@BrentBaccala
Copy link
Contributor

Seems to be working fine now. I'm no longer seeing the SSL handshake errors and it seems to work fine either with or without NAT. I haven't tested Greenlight.

There was some discussion of trying to do this with a newer nginx, but I think we should go with this PR in its present form.

@ffdixon ffdixon merged commit 492d83b into bigbluebutton:master Jan 24, 2023
@anandchristudas
Copy link

The TURN server doesn't get connected if the IP address is proxied through Cloudflare. Is it possible to proxy the IP address using Cloudflare and still use the TURN server?

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.

None yet

7 participants