Build a self managed video conference service with a lightweight server and integrate it into your own project

This paper is mainly for readers who need to integrate video conference in their own system.

The customer asked to integrate the video conference function in the page. Originally, it was just going to be implemented directly with Tencent cloud services, but the customer said that they are completely a LAN environment that cannot access the Internet, so they need to deploy a self managed video conference server, and the video conference server needs to provide corresponding interfaces to integrate with their own projects. After some research, we found some good third-party open source projects. Today is one of them openvidu , it adopts WEBRTC technology, and its functions can basically meet our current needs, and it is very convenient to deploy with Docker.

Although openvidu also provides the Web page of video conference, it is very simple. It is mainly for the development users to integrate the video conference function in the system developed by itself.

The early test is mainly run in the public network environment, so it is necessary to purchase a public network server for development and testing. According to the requirements of the official website, the server configuration requires at least 2-core CPU and 8G memory configuration, and sufficient bandwidth. Considering the cost, we finally bought it Tencent cloud lightweight server The 4-core 8G10M bandwidth configuration will be deployed and built based on this server in the future.

Due to the limitation of the browser security protocol, the browser will prohibit the use of the camera on the HTTP protocol page except after accessing with the localhost address. Therefore, you need to configure the certificate in the following procedure. openvidu supports configuring certificates by itself and automatically issuing certificates using letsencrypt. If you use letsencrypt to automatically issue the certificate, you need to use the domain name to point to the server IP, and the domestic server domain name needs to be filed. If there is no registered domain name, you can choose to purchase a lightweight server with the same configuration as Hong Kong.

Purchase server

If there is no server, you need to buy a lightweight server of Tencent cloud first.

Lightweight application server TencentCloud Lighthouse is a new generation of out of the box cloud server product for lightweight application scenarios. It helps small and medium-sized enterprises and developers to easily and efficiently build websites, applets / games, e-commerce, cloud disk / drawing bed and various development, testing and learning environments in the cloud. Compared with ordinary cloud servers, TencentCloud Lighthouse is easier to use, provides high bandwidth traffic packages and integrates them in the form of packages Selling basic cloud resources and integrating and packaging popular open source software to build applications with one click is the best way for you to use Tencent cloud. To facilitate application installation, we need to prepare the Docker environment.

Docker is an open source application container engine, which allows developers to package their applications and dependent packages into a portable container, and then publish them to any popular Linux or Windows operating system machine. It can also realize virtualization. The container completely uses the sandbox mechanism without any interface with each other. Using docker to deploy applications is very simple. Generally, it only needs one line of command.

Tencent cloud often holds various activities, which can Click here to enter their activity page For purchase (note that the configuration should be at least 8G according to the requirements of the official website), you can choose the nearest region for purchase, but if you don't want to record, you can choose an overseas server (such as Hong Kong region) for purchase. For image, select docker basic image under official image, select the instance package that is suitable for you, and then submit the order for payment. If you do not select docker basic image, you need to install the docker container yourself.

Install docker and docker compose

If the docker basic image is not selected, you need to install the docker image yourself. This assumes that the Ubuntu system is used. The steps to install docker are as follows

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Then install docker compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
 sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version

Configure security groups

WEBRTC technology is used inside the video conference function, and more ports will be used. Therefore, the corresponding ports need to be released on the firewall policy of the lightweight server. At present, the ports required to be opened on the official website are as follows.

22: TCP: SSH port

80 TCP: HTTP port

443 TCP:HTTPS port

3478 TCP+UDP: TURN server port. TURN server is used for traffic forwarding when both video parties cannot directly establish a point-to-point connection

40000 - 57000 TCP + UDP: the port on which kurento media server establishes a media connection

57001 - 65535 TCP + UDP: the port on which the turn server establishes a media connection.

In addition, please ensure that these ports 80, 443, 3478, 5442, 5443, 6379 and 8888 cannot be occupied

If it is troublesome and only used by the test environment, all ports can be released directly.

Domain name resolution

Resolve the domain name to be used to the IP of the server. If a domestic server is used, the domain name needs to be filed. If there is no registered domain name, you need to buy a server in Hong Kong. Or you can use IP directly without using domain name. If you use IP directly, you need to issue and configure the certificate and configure the browser trust certificate yourself.

Start installation deployment

After the preparations are finished, you can start downloading and installing. It is installed in the / opt directory by default

First enter the / opt directory

cd /opt

Then use the script provided by openvidu to install

curl https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/install_openvidu_latest.sh | bash

Due to policy reasons, the download may fail on the domestic server. You can install it in the scientific Internet environment first, and then upload the corresponding files to the installation directory of the server.

Enter the openvidu directory

cd /openvidu

Use familiar tools to edit env file. In this document, letsencrypt is used to automatically issue certificates (ov's default option). You only need to modify the following configurations.

DOMAIN_OR_PUBLIC_IP=Own domain name
OPENVIDU_SECRET=xxxxxx                #Replace the key with a high security factor
LETSENCRYPT_EMAIL=xx@xx.com    #Change to your own mailbox

Or, instead of issuing a certificate using letsencrypt, configure the certificate from the row. The specific configuration method is shown in Detailed description is provided in env file.

# OpenVidu configuration
# ----------------------
# Documentation: https://docs.openvidu.io/en/stable/reference-docs/openvidu-config/

# NOTE: This file doesn't need to quote assignment values, like most shells do.
# All values are stored as-is, even if they contain spaces, so don't quote them.

# Domain name. If you do not have one, the public IP of the machine.
# For example: 198.51.100.1, or openvidu.example.com
DOMAIN_OR_PUBLIC_IP=

# OpenVidu SECRET used for apps to connect to OpenVidu server and users to access to OpenVidu Dashboard
OPENVIDU_SECRET=

# Certificate type:
# - selfsigned:  Self signed certificate. Not recommended for production use.
#                Users will see an ERROR when connected to web page.
# - owncert:     Valid certificate purchased in a Internet services company.
#                Please put the certificates files inside folder ./owncert
#                with names certificate.key and certificate.cert
# - letsencrypt: Generate a new certificate using letsencrypt. Please set the
#                required contact email for Let's Encrypt in LETSENCRYPT_EMAIL
#                variable.
CERTIFICATE_TYPE=selfsigned

# If CERTIFICATE_TYPE=letsencrypt, you need to configure a valid email for notifications
LETSENCRYPT_EMAIL=user@example.com

After all are configured, run the following command to start

./openvidu start

This command will pull and start the docker image of the corresponding service. After execution, use docker ps to see the started container

After startup, access https://xxx.xxx.xxx.xxx:port Verify the server.

If you open the following page, it means that you have succeeded 50%.

Then open more pages on the tab and add the same room to test the effect. If you see the following screen, the configuration has been successful.

Integration with your own system

openvidu provides SDK s for various languages and frameworks, including server and client, and provides a large number of examples that can be copied and pasted directly. As long as the above services are configured, it only takes more than ten minutes to integrate into your own system.

The github address provided by the official example is https://github.com/OpenVidu/openvidu-tutorials

Examples provided are

The following is the effect diagram of my integration in my VUE project. The core code is an example of direct replication.

Finally

openvidu is a very excellent open source video conference server, and Tencent cloud lightweight server is also a very cost-effective server. The cooperation of the two complement each other. You also know some similar open source video conferencing services. Let's recommend them.

Added by abigbluewhale on Fri, 24 Dec 2021 09:07:55 +0200