Install Janus Webrtc Ubuntu Server 18.04.4

Source: https://github.com/meetecho/janus-gateway

Ubuntu 18.04.4

Error

E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/repo.mongodb.org_apt_ubuntu_dists_bionic_mongodb-org_4.0_multiverse_binary-amd64_Packages
E: The package lists or status file could not be parsed or opened.

=> Fix

sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update

Install script

sudo apt install libmicrohttpd-dev libjansson-dev libssl-dev libsrtp-dev libsofia-sip-ua-dev libglib2.0-dev libopus-dev libogg-dev libcurl4-openssl-dev liblua5.3-dev libconfig-dev pkg-config gengetopt libtool automake gtk-doc-tools doxygen graphviz libnanomsg-dev cmake -y --fix-missing

# Install libnice
cd ~
git clone https://gitlab.freedesktop.org/libnice/libnice
cd libnice
./autogen.sh
./configure --prefix=/usr
make && sudo make install

# Install libsrtp2
cd ~
wget https://github.com/cisco/libsrtp/archive/v2.2.0.tar.gz
tar xfv v2.2.0.tar.gz
cd libsrtp-2.2.0
./configure --prefix=/usr --enable-openssl
make shared_library && sudo make install

# Install usrsctp
cd ~
git clone https://github.com/sctplab/usrsctp
cd usrsctp
./bootstrap
./configure --prefix=/usr && make && sudo make install

# Install libwebsockets
cd ~
git clone https://libwebsockets.org/repo/libwebsockets
cd libwebsockets
# If you want the stable version of libwebsockets, uncomment the next line
# git checkout v2.4-stable
mkdir build
cd build
# See https://github.com/meetecho/janus-gateway/issues/732 re: LWS_MAX_SMP
cmake -DLWS_MAX_SMP=1 -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
make && sudo make install

# Install MQTT C
cd ~
git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
make && sudo prefix=/usr make install

# Install RabbitMQ
cd ~
git clone https://github.com/alanxz/rabbitmq-c
cd rabbitmq-c
git submodule init
git submodule update
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
make && sudo make install

# Install janus
cd ~
git clone https://github.com/meetecho/janus-gateway.git
cd janus-gateway
sh autogen.sh
./configure --prefix=/opt/janus
make
sudo make install
sudo make configs 

Config at

/opt/janus/etc/janus/janus.jcfg

Start

sudo /opt/janus/bin/janus

# run background: https://janus.conf.meetecho.com/docs/service.html
# or use multi terminal
screen -S janus -d -m
screen -r janus
[CTRL+A+D to detach again]

API start at 

localhost:8088/janus

# Get server info
http://localhost:8088/janus/info

Websocket at

localhost:8188

Setup ssl

cd ~
mkdir ssl
cd ssl

# Gen ssl certs:
openssl req -new -newkey rsa:4096 -nodes -keyout key.pem -out cert.csr
openssl x509 -req -sha256 -days 365 -in cert.csr -signkey key.pem -out cert.pem
chmod 600 cert.csr
chmod 600 cert.pem
chmod 600 key.pem

Update config

#Janus config
sudo nano /opt/janus/etc/janus/janus.jcfg
=> to
certificates: {
        cert_pem = "/home/nhancv/ssl/cert.pem"
        cert_key = "/home/nhancv/ssl/key.pem"
        #cert_pwd = "secretpassphrase" #secretpassphrase
}

#Http transport config
sudo nano /opt/janus/etc/janus/janus.transport.http.jcfg
=> to
general: {
        http = true # Whether to enable the plain HTTP interface
        port = 8088 # Web server HTTP port
        https = true # Whether to enable HTTPS (default=false)
        secure_port = 8089 # Web server HTTPS port, if enabled
}
certificates: {
        cert_pem = "/home/nhancv/ssl/cert.pem"
        cert_key = "/home/nhancv/ssl/key.pem"
        #cert_pwd = "secretpassphrase" #secretpassphrase
}

Restart
sudo /opt/janus/bin/janus

If you got error and can not proceed https on Chrome, just move to Firefox
https://localhost:8089/janus/info

To run demo

Clone: https://github.com/meetecho/janus-gateway

Install local webserver: https://www.npmjs.com/package/local-web-server

npm install -g local-web-server

Start local demo: 

cd janus-gateway/html
ws --http2

# Test at https://127.0.0.1:8000

# Note: You need to modify janus server point to your server address on specific js demo file. Such as: videocalltest.js

Leave a Reply

Your email address will not be published.Required fields are marked *