Red5 Documentation

Create Stream Manager 2.0 Instance

The Stream Manager 2.0 instance is the cornerstone of Red5 Pro’s architecture, providing a comprehensive solution for managing, orchestrating, and scaling your streaming infrastructure.

Stream Manager 2.0 instance consists of multiple Docker containers (microservices) and runs using Docker Compose.

Create Stream Manager 2.0 Instance

Go to Linodes → Create Linode

  • Select region from drop down. Example → US, Los Angeles, CA (us-lax)
  • Choose an OS: Select Ubuntu 22.04 LTS
  • Linode Plan: Choose Dedicated 4 GB in dedicated CPU plan category
  • Details: Provide label to instance. Example → red5pro-autoscaling-sm-instance
  • Security: Enter strong password for root user and select the SSH key added in the previous step
  • VPC: Select vpc and subnet created in previous step
    • Select both the checkbox option
      • Auto-assign a VPC IPv4 address for this Linode in the VPC
      • Assign a public IPv4 address for this Linode
  • Firewall: Choose the firewall rule of nodes created in the previous step. Example → red5pro-autoscaling-sm-sg
  • Click on Create Linode

Create new DNS record for Stream Manager 2.0 Instance

The default configuration requires creating a DNS record and using an SSL certificate on the Stream Manager 2.0 to allow clients to publish and subscribe to WebRTC streams using a browser.

  1. Find the public IP address of your Stream Manager 2.0 instance.
  2. Create an A record in your DNS provider to point the DNS name to the public IP address.
red5pro-sm2.example.com - 1.2.3.4

If you choose not to install a domain name and SSL certificate, you will not be able to publish WebRTC streams. However, you will still be able to publish RTMP and RTSP streams and subscribe to WebRTC, RTMP, and RTSP streams. In this case, you will need to use the docker-compose.yml file that does not include SSL certificate configuration. Example: autoscaling-without-ssl

Install Stream Manager 2.0 Instance

  1. Connect to your instance over ssh as root user. Example: ssh -i ssh_private_key.pem root@1.2.3.4

  2. Install docker with docker-compose-plugin, follow the public documentation.

  3. Create folder for Stream Manager 2.0 files.

sudo mkdir /usr/local/stream-manager
  1. Pull Stream Manager 2.0 docker-compose examples from our public repository red5pro-stream-manager-2-examples.
git clone https://github.com/red5pro/red5pro-stream-manager-2-examples.git
  1. Choose one deployment type from examples. Example with SSL ceritificate: autoscaling-with-ssl
  2. Copy files from folder autoscaling-with-ssl to the folder /usr/local/stream-manager
sudo cp -r ./red5pro-stream-manager-2-examples/autoscaling-with-ssl/. /usr/local/stream-manager/
  1. Go to the Stream Manager folder
cd /usr/local/stream-manager/
  1. Create folder for SSL certificate
sudo mkdir /usr/local/stream-manager/letsencrypt
  1. Rename docker compose variables file
sudo mv /usr/local/stream-manager/.example.env /usr/local/stream-manager/.env
  1. Set main Stream Manager 2.0 variables in the file /usr/local/stream-manager/.env
R5AS_AUTH_SECRET=<SECRET_KEY>
R5AS_AUTH_USER=<USER_NAME>
R5AS_AUTH_PASS=<PASSWORD>
R5AS_CLOUD_PLATFORM_TYPE=<PLATFORM_TYPE>
KAFKA_HOST=<PRIVATE_IP>
TRAEFIK_HOST=<DNS_NAME>
TRAEFIK_SSL_EMAIL=<EMAIL>
R5P_LICENSE_KEY=<LICENSE_KEY>
  • R5AS_AUTH_SECRET – Authentication secret used to create and authenticate JWTs. Example: 12345abcd
  • R5AS_AUTH_USER – Authentication user name used to get JWT token. Example: admin
  • R5AS_AUTH_PASS – Authentication user password used to get JWT token. Example: password
  • R5AS_CLOUD_PLATFORM_TYPE – Cloud platform type (OCI,AWS,LINODE). Example: LINODE
  • KAFKA_HOST – Kafka server IP address. In this deployment Kafka server on the Stream Manager 2.0 instance so you will need to set Private IP address of this instance. Example: 10.0.0.10
  • TRAEFIK_HOST – Stream Manager 2.0 domain name: This should be the same domain name you used to create the DNS record. Example: red5pro-sm2.example.com
  • TRAEFIK_SSL_EMAIL – The email address that will be used for the SSL certificate.
  • R5P_LICENSE_KEY – Red5 Pro license key which will be using on the Red5 Pro nodes. It should be active Red5 Pro license key, Startup Pro level or higher.
  1. Set Linode Cloud specific variables in the /usr/local/stream-manager/docker-compose.yml file.
    TF_VAR_linode_api_token: api123token...
    TF_VAR_linode_root_user_password: linode@password..
    TF_VAR_linode_ssh_key_name: red5pro_ssh_public_key

You should have these variables from the previous steps.

  • TF_VAR_linode_api_token – Linode API token to authenticate with cloud. Follow the docs to create.
  • TF_VAR_linode_root_user_password – Provide the root user password for Red5 Pro nodes. Root user password must lies between 11-64 character.
  • TF_VAR_linode_ssh_key_name – SSH key name. It will be using for SSH connect to Red5 Pro nodes. Follow the docs to create SSH key pair in Linode.

Example as-terraform service configuration for LINODE

  as-terraform:
    deploy:
      replicas: 1
    image: red5pro/as-terraform:latest
    depends_on:
      kafka0:
        condition: service_healthy
    environment:
      R5AS_AUTOSCALE_PARTITIONS: 2
      R5AS_REPLICATION_FACTOR: 1
      R5AS_BOOTSTRAP_SERVERS: kafka0:29092
      R5AS_SECURITY_PROTOCOL_CONFIG: ""
      R5AS_SSL_KEYSTORE_TYPE_CONFIG: ""
      R5AS_SSL_TRUSTSTORE_TYPE_CONFIG: ""
      R5AS_SSL_CA_CERTIFICATE: ""
      R5AS_SASL_USERNAME: ""
      R5AS_SASL_PASSWORD: ""
      R5AS_SASL_ENABLED_MECHANISMS: ""
      R5AS_COMMAND_INACTIVITY_GAP_MS: 10000
      TF_VAR_linode_api_token: api123token...
      TF_VAR_linode_root_user_password: linode@password..
      TF_VAR_linode_ssh_key_name: red5pro_ssh_public_key
      TF_VAR_r5p_license_key: ${R5P_LICENSE_KEY:?R5P_LICENSE_KEY is not set}

  1. Start/Stop Stream Manager 2.0 – docker compose
  • sudo docker compose up -d – Start the Docker Compose services defined in the docker-compose.yml file in detached mode.
  • sudo docker compose up – Start the Docker Compose services defined in the docker-compose.yml file.
  • sudo docker compose logs -f – Follow the logs of all running services in real-time.
  • sudo docker compose down – Stop and remove all the services defined in the docker-compose.yml file.

To run Docker Compose commands, you should be in the directory containing the docker-compose.yml file. In this case, it is the /usr/local/stream-manager directory.

  1. Create service to allow for ease of startup/shutdown of Stream Manager 2.0, in addition to automatically starting the service on server reboot, you will want to add a systemd unit file for Stream Manager 2.0.
  • Create a service file:
sudo nano /lib/systemd/system/sm.service
  • Add the following content to the service file:
[Unit]
Description=Stream Manager 2.0
Requires=docker.service
After=docker.service
StartLimitIntervalSec=60

[Service]
WorkingDirectory=/usr/local/stream-manager
ExecStart=/usr/bin/docker compose up
ExecStop=/usr/bin/docker compose down
TimeoutStartSec=0
Restart=on-failure
StartLimitBurst=3

[Install]
WantedBy=multi-user.target 
  • Start the service:
sudo systemctl start sm.service
  • Stop the service:
sudo systemctl stop sm.service
  • Restart the service:
sudo systemctl restart sm.service
  • Enable the service to start on boot:
sudo systemctl enable sm.service
  • Check the status of the service:
sudo systemctl status sm.service
  1. Verify Stream Manager 2.0

To verify that the Stream Manager 2.0 is running correctly, open your web browser and navigate to the following URL: https://<STREAM_MANAGER_DOMAIN_NAME>. If you are using the Stream Manager 2.0 without an SSL certificate and domain name, use http://<STREAM_MANAGER_IP_ADDRESS> instead.

You should see the Stream Manager 2.0 interface if everything is set up correctly.