A description how to set up and run Element Call with the SFU on a local machine.
Please note this all is still work in progress and will change in the future.
To run Element Call local we need three components:
- A Matrix Home Server like Synapse, Dentrite, ...
- The SFU Waterfall
- Element Call Element Call
As a backend we use Synapse and docker to build them.
Synapse takes over the user and the room management and the event handling for the connection establishment. To do this, we later need to create users in Synapse . Important information is that SFU also registers with an SFU user account on the Homeserver Synapse. But first we'll set up Synapse and build a configuration for them.
We'll set up Synapse in a way that's it will store the database files as well as the configuration files in a local data directory. Having it local makes it much easier to do changes on it.
Run the following commands in a directory of your choice!
Create a data
directory.
mkdir data
As next let us create a default Synapse configuration in data
folder.
docker run -it --rm \
-v $(pwd)/data:/data \
-e SYNAPSE_SERVER_NAME=localhost \
-e SYNAPSE_REPORT_STATS=no \
matrixdotorg/synapse:latest generate
Let us customize the data/homeserver.yml
configuration a little.
This will make our live easier in local development process:
Activate unsecure registration: Its help us to register users easier:
For this add the following lines in the data/homeserver.yml
enable_registration: true
enable_registration_without_verification: true
Deactivate Reporting by adding this:
report_stats: false
Increase the Rate Limit: Because we need to do sometime load testing, it is a good thing that's Synapse allows massive logins from the same IP.
For this add the following lines in the data/homeserver.yml
rc_login:
address:
per_second: 15
burst_count: 5
account:
per_second: 18
burst_count: 4
failed_attempts:
per_second: 19
burst_count: 7
docker run -d --name shadowfax-synapse \
-v $(pwd)/data:/data \
-p 8008:8008 \
matrixdotorg/synapse:latest
We need to create the SFU user in Synapse.
docker exec -it shadowfax-synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml -u sfu -p sfu --no-admin
docker exec -it shadowfax-synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml -u user1 -p user1 --no-admin
docker exec -it shadowfax-synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml -u admin -p admin --admin
Start Synapse and run the API login request:
curl -XPOST \
-d '{"type":"m.login.password", "user":"sfu", "password":"sfu"}' \
"http://localhost:8008/_matrix/client/r0/login"
{
"user_id": "@sfu:localhost",
"access_token": "<<ACCESS_TOKEN>>",
"home_server": "localhost",
"device_id": "<<SFU_DEVICE_ID>>"
}
Sometimes it is nice to see what happen in the Homeserver. For this you can use this tool and the admin user we created a step previous to login.
docker run -d -p 8081:80 awesometechnologies/synapse-admin
Element Call is the frontend component. The main part of the WebRTC logic you will find is in the Matrix JS SDK. Element Call needs to know the SFU in order to connect to it. For this checkout the project with the current feature branch:
git clone https://github.com/vector-im/element-call.git
git checkout feature-sfu
In case you'll develop on the Matrix JS SDK you'll also want to yarn link the js-sdk like
git clone https://github.com/matrix-org/matrix-js-sdk.git
cd matrix-js-sdk
git checkout matthew/sfu
yarn
yarn link
Create a config file (element-call/public/config.json
) in the public folder of the root of the project with the follow content:
{
"default_server_config": {
"m.homeserver": {
"base_url": "http://localhost:8008",
"server_name": "localhost"
}
},
"temp_sfu": {
"user_id": "@sfu:localhost",
"device_id": "<<SFU_DEVICE_ID>>"
}
}
Check out the main branch of the SFU and then first create a config.yaml
in the root directory of the SFU.
git clone https://github.com/matrix-org/waterfall.git
cd waterfall
cp config.sample.yaml config.yaml
Find the following lines of config and change them with your <<ACCESS_TOKEN>> and your local settings.
matrix:
homeserverUrl: "http://localhost:8008"
userId: "@sfu:localhost"
accessToken: "<<ACCESS_TOKEN>>"
...
Start the SFU in your preferred way. For example:
go run ./cmd/sfu
Because the config.yaml
is in the root the app will find them by convention.
If you put the config.yaml
in another director add the config path on the run command with go run ./cmd/sfu --config path/config.yaml
That's it! Have fun!