Simple WebSocket Server for hosting Mixer Backend
This Node.js-based WebSocket server provides the communication between the Stream Manager Mixer testbeds, which moderators use to create compositions, and the HTML5 pages with sample layouts that are loaded into Red5 Pro Mixers and are responsible for defining the layout of the composite streams. This allows for creating dynamic compositions or video conferences where a Manager or Host can add or remove live streams in real time. Additionally, the node.js server can provide the endpoints for round-trip authentication if used.
- NodeJS v10+
- NPM 6+
This project was developed with the latest NodeJS & NPM as of the time of this writing (December 2021).
Install Prerequisites
sudo apt-get update
curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install -y nodejs
sudo apt-get install build-essential
sudo npm install forever -g
cd into the project directory, then run:
npm install
For most NodeJS implementations, it is necessary to generate SSL certificate files, which are converted into .crt and .key files to be stored in the <service>/cert
folder.
The following can be run to install Let's Encrypt Certbot on Ubuntu (snap
is included with most Ubuntu distributions by default)
- sudo snap install core; sudo snap refresh core
- sudo snap install --classic certbot
- sudo ln -s /snap/bin/certbot /usr/bin/certbot
To generate the cert, run sudo certbot certonly --standalone --email <your-email> --agree-tos -d <server-fqdn>
(for example: sudo certbot certonly --standalone --email [email protected] --agree-tos -d test01.red5.net
)
You will then need to copy the fullchain and privatekey to the cert directory of your application
sudo cp /etc/letsencrypt/live/<server-fqdn>/fullchain.pem ~/<nodejs-server>/cert/certificate.crt
sudo cp /etc/letsencrypt/live/<server-fqdn>/privkey.pem ~/<nodejs-server>/cert/privateKey.key
sudo chmod +r ~/<nodejs-server>/cert/*
Your index.js file then needs to be modified with the full path to the certificate and privateKey files (replace with the appropriate paths):
if (useSSL) {
cert = fs.readFileSync('/home/ubuntu/serverapp/cert/certificate.crt')
key = fs.readFileSync('/home/ubuntu/serverapp/cert/privateKey.key')
port = 443
NOTE
There are multiple index.js
files. The upper level index.js
does not support the Grid Composition Test. To support this test, cd
to ~/nodejs-mixer-backend/backend-mixer-testbeds
Start the Node.js server with the following command:
sudo PORT=443 SM_TOKEN=<SM-API_token> SM_HOST=https://<Hostname-of-Stream-Manager> CERT=<path-to-fullchain.pem> KEY=<path-to-fullchain.pem> forever start -w index.js
By default, if PORT is not specified, the websocket server will run on
localhost:8001
.
The backend-mixer-testbeds
directory is required for creating mixer compositions.
forever list
: displays any running forever processes.forever start
: starts a script as a daemon.forever stop
: stops the daemon script byId|Uid|Pid|Index|Script
.forever stopall
: stops all running scripts.forever restart
: restarts the daemon script.forever restartall
: restarts all running forever scripts.