Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

This is an experimental relay (optimized for low latency media transfers) that implements IETF MOQ protocol

License

Notifications You must be signed in to change notification settings

facebookexperimental/moq-go-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This code is NO longer manteined, it is superseeded by moxygen

moq-go-server

This is an experimental media MOQ relay (AKA: CDN node) based on MOQT draft-01. It can be used in conjunction with following live encoder and player moq-encoder-player. Both repos allows us create a live streaming platform where we can control latency and quality (and others), so we can test scenarios from ultra low latency live (video call) to high quality (and high scale) live.

Basic block diagram Fig1: Basic block diagram

In the following figure you can see an overview of the relay architecture

Relay architecture overview Fig1: Relay architecture overview

Installation

To install this server in a CentOS linux instance follow the next steps:

  • Create a new user, and add it to sudoers

  • Configure firewall to allow:

    • Inbound
      • SSH: 22 TCP (From: [up to you])
      • WT: 4433 UDP (From: everywhere IPv4 and IPv6)
      • HTTPs: 443 (From: everywhere IPv4 and IPv6)
      • HTTPs: 80 [Optional, just testing] (From: everywhere IPv4 and IPv6)
    • Outbound
      • ALL
  • Update server

sudo yum update -y
  • Install dependencies
sudo yum install git tmux -y
  • Install go version go1.20+
sudo yum install golang -y
  • Install and activate a webServer
sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd
sudo yum install mod_ssl -y
  • Configure certificates (needed for WebTransport)

    • You can use any process you want to install valid signed certificates. We used LetEncrypt
  • Configure Apache

    • Edit the main Apache configuration file /etc/httpd/conf/httpd.conf. Locate the "Listen 80" and add the following lines after it, replacing the example domain names.
<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName "yourdomain.com"
    ServerAlias "subdomain.yourdomain.com"
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot "/var/www/html"
    ServerName "yourdomain.com"
    ServerAlias "subdomain.yourdomain.com"

    SSLEngine on
    SSLCertificateFile "/etc/letsencrypt/live/subdomain.yourdomain.com/fullchain.pem"
    SSLCertificateKeyFile "/etc/letsencrypt/live/subdomain.yourdomain.com/privkey.pem"
</VirtualHost>
  • Configure certificates

    • In this stage stage you will need to show that you own the domain you are trying to configure (You will need to answer some questions)
  • Clone this repo

git clone git@github.com:facebookexperimental/moq-go-server.git
  • Compile it
cd moq-go-server/src
go build
  • Copy previously generated certs to allow this server to use them (careful with renewals)
cd ..
mkdir certs
sudo cp /etc/letsencrypt/live/subdomain.yourdomain.com/privkey.pem certs/certificate.key
sudo chmod 644 certs/certificate.key
sudo cp /etc/letsencrypt/live/subdomain.yourdomain.com/cert.pem certs/certificate.pem
  • Start server inside tmux
tmux
cd src
./moq-go-server

See details on how use / set up this system as a live streaming relay in moq-encoder-player testing

Origins

This implementation allows relay to relay communication.

Origns block diagram

The way this works is the follwing:

  • When relay starts reads the json file pointed by --moq_origins_config, example ./origins/example-origins.json (or see below)
  • It opens (and keep opened) an MOQT connection to all other relays it finds in that file
  • The ANNOUNCE messages are kept in the relay where encoder is connected
  • The SUBSCRIBE messages that does NOT find any local producer that matches its tracknamespace are forwarded to all the relays that offers that tracknamespace (via tracknamespace in its config)

Example of origin config:

{
  "origins": [
    {
      "friendlyname": "test",
      "guid": "3ea8e44a82784c7ba0c107b78d9dea9a",
      "tracknamespace": "simplechat-relay",
      "authinfo": "my super secret",
	    "originaddress" : "https://localhost:4455/moq",
      "origincertpath": "./my-cert.pem"
    }
  ]
}

Testing

It is recommended that you test on a server with valid certificate. To facilitate debugging you can:

  • Install delve
sudo go install github.com/go-delve/delve/cmd/dlv@latest
  • Build app for debug
cd src
go build -gcflags="all=-N -l"
  • Run in debug mode in the remove machine
cd src
[GO PATH]/go/bin/dlv --listen=:2345 --headless=true --log=true --accept-multiclient --api-version=2 exec moq-go-server -- --listen_addr ":4455"

Note: The delve listen port needs to be open in that remote machine

  • Connect VSCode (or other IDE) to that remote machine In this link you can find a good guide

Note: Webtransport implementation of QUIC-GO currently does NOT allow localtesting, see open issue

License

moq-go-server is released under the MIT License.

About

This is an experimental relay (optimized for low latency media transfers) that implements IETF MOQ protocol

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published