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

WebRTC support with Coturn #16

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

WebRTC support with Coturn #16

wants to merge 10 commits into from

Conversation

keianhzo
Copy link
Contributor

@keianhzo keianhzo commented Nov 11, 2022

Why

We need to test WebRTC comms in the containerized version of the Hubs infra but the current config doesn't support it.

What

This PR assigns a public IP and opens ports for RTC comms in the dialog config for hhost to host communication. It also adds a new container for the TURN server for tcp/udp relayed communication.

@keianhzo keianhzo requested a review from bryanenders November 11, 2022 15:38
@keianhzo keianhzo changed the title Coturn support Full WebRTC support Nov 11, 2022
@keianhzo keianhzo requested a review from tanfarming November 11, 2022 15:38
@keianhzo keianhzo changed the title Full WebRTC support WebRTC support Nov 11, 2022
name: mozilla-hubs
ipam:
Copy link
Contributor

Choose a reason for hiding this comment

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

Today I learned that ipam stands for IP address management.

Copy link
Contributor

@bryanenders bryanenders left a comment

Choose a reason for hiding this comment

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

I left some questions and suggestions. Could you also please remove the .DS_Store file? (You might consider adding it to your global gitignore.)

README.md Outdated Show resolved Hide resolved
networks:
default:
hubs_network:
Copy link
Contributor

Choose a reason for hiding this comment

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

The default applies the custom network (mozilla-hubs) to all the services. When you remove default you then have to specify the network for each service. That makes sense when you are divvying up the services between multiple networks, but we aren’t doing that. What’s the benefit in ditching the default here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC it was required to assigning a static ip address.

@@ -9,6 +31,10 @@ services:
user: postgres
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a smell. Why do we need to expose the database to the host OS?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Coturn needs to access the database. Is there another better way of inter container communication?

Copy link
Contributor

Choose a reason for hiding this comment

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

Containers on the same network can reach one another. The ports configuration maps the container port to the port on the host OS. So in this case, that’s HOST:CONTAINER which maps port 5432 from the container to the same port on the host OS. Will software on your local machine need to access the database directly?

docker-compose.yml Outdated Show resolved Hide resolved
# This should be the same as MEDIASOUP_MIN_PORT and MEDIASOUP_MAX_PORT
# You might neeed to increase this number depending on how many client you are connecting.
# (Keep the ports range small to improve container statup time)
- "40000-40050:40000-40050"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these ports need to be exposed to the host OS? If so, does the user need to accept proxy certificates in the browser for them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This are used for Coturn <-> Dialog communication but again this is the only way I found to communicate two containers. Open to hear alternatives.

Copy link
Contributor

Choose a reason for hiding this comment

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

The ports config shouldn’t affect communication between two services on the same network. They are able to communicate directly without the intervention of the host OS.

volumes:
- dialog:/code
working_dir: /code
networks:
hubs_network:
ipv4_address: 10.20.30.12
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it necessary to fix the address to a static IP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You need to listen in a specific IP address, you can't listen in all interfaces. Is there a better way to assign the current container IP without making it static?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don’t follow. Does it need to be the same between orchestrations? Who is listening?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we just need to know the current container IP, then # hostname -i should do the trick.

COPY files/coturn/certs/key.pem /certs/key.pem
COPY files/coturn/certs/cert.pem /certs/cert.pem
COPY files/coturn/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

If you chmod the file in the repo, then you don’t have to in the dockerfile.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add a newline to the end of the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are permissions kepts accross different OSs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Affirmative. The file permission comes from the build context.

build:
context: .
dockerfile: dockerfiles/coturn.Dockerfile
entrypoint: /bin/sh /entrypoint.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

What would you think about moving this line directly into the dockerfile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yep, I see that you have been moving those. What the benefit of doing that? image reusability?

Copy link
Contributor

Choose a reason for hiding this comment

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

It makes the compose file lighter and more focused on orchestration (rather than containerization). If that makes sense. 😄

files/coturn/entrypoint.sh Outdated Show resolved Hide resolved
.dockerignore Outdated Show resolved Hide resolved
coturn:
environment:
REALM: ret
PSQL: host=db dbname=ret_dev user=postgres password=postgres options='-c search_path=coturn' connect_timeout=30
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need access to Reticulum’s database? If not, it should get its own and probably its own host too since the version of Postgres Reticulum needs may differ from that of coturn.

@bryanenders
Copy link
Contributor

What feature(s) am I able to exercise with this addition that I was unable to without it?

@bryanenders
Copy link
Contributor

When I run this branch locally I get errors about missing tables. How are the necessary tables meant to be created?

@keianhzo keianhzo mentioned this pull request Jul 14, 2023
@keianhzo keianhzo changed the title WebRTC support WebRTC support with Coturn Jul 14, 2023
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