Installing Red5 Pro on an Ubuntu Linux Server

The following describes the steps in installing Red5 Pro on an Ubuntu linux server. We recommend running Red5 Pro on linux for optimal performance.


Software Dependencies - Ubuntu

You will need to install Java (recommended version 8 or higher) and unzip to run and deploy Red5 Pro server.

Depending on your permissions, you may need to pre-pend the following commands with sudo:

$ apt-get update
$ apt-get install default-jre
$ apt-get install unzip

Depending on your version of Ubuntu, you may also need to install the following libraries to support WebRTC:

$ apt-get install libva1
$ apt-get install libva-drm1
$ apt-get install libva-x11-1
$ apt-get install libvdpau1

Software Dependencies - CentOS

Note: Red5 Pro with WebRTC does not run on CentOS 6 due to an older and less secure version of glibc that has been updated with CentOS 7. If you want to run Red5 Pro on CentOS, you must use build 7 or higher.

Depending on your permissions, you may need to pre-pend the following commands with sudo:

$ yum -y update
$ yum -y install java
$ yum -y install unzip
$ rpm --import http://packages.atrpms.net/RPM-GPG-KEY.atrpms
$ rpm -ivh http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm
$ yum -y update --skip-broken
$ yum -y --enablerepo=atrpms install libva libvdpau1

Red5 Pro Installation

To install the Red5 Pro Server:

  1. Download the server .zip distribution to your local machine. Make sure to login with your account on http://account.red5pro.com and download the server from https://account.red5pro.com/download.
  2. SFTP the server .zip distribution into the /tmp directory of your server
  3. Choose a location to run your instance and navigate to that directory. For this example, we’re running from /usr/local
$ cd /usr/local
  1.  Copy the server distribution to this directory:
$ sudo cp /tmp/red5pro-server-xxx.zip
  1.  Unzip the Red5 Pro distribution in the directory:
$ sudo unzip red5pro-server-xxx.zip
  1.  For ease of use, rename the Red5 Pro distribution directory to red5pro:
$ sudo mv red5-server-xxx-release red5pro

If you have a Professional License Key

If you have purchased a Red5 Pro Professional license from http://account.red5pro.com, then you need to add it to the root of the Red5 Pro Server installation:

Replace YOUR-LIC-ENSE-KEY1 with the license key provided from your Red5 Pro Professional account:

$ cd /usr/local/red5pro
$ sudo printf 'YOUR-LICE-ENSE-KEY1' > LICENSE.KEY

Add execute permissions to the following files:

sudo chmod +x *.sh will do the job.

Modify Maximum Java Heap Size For Red5 Pro Java Process

You can modify the maximum Java heap size by modifying red5.sh. Increasing the maximum heap size will allow the server to assign as much memory as is available to Red5 Pro when necessary.

The default maximum heap size is 2 gigabytes (-Xmx2g).

# JAVA options
# You can set JVM additional options here if you want
if [ -z "$JVM_OPTS" ]; then
    JVM_OPTS="-Xms256m -Xmx2g -Xverify:none -Djava.net.preferIPv4Stack=true -XX:+TieredCompilation -XX:+UseBiasedLocking -XX:InitialCodeCacheSize=8m -XX:ReservedCodeCacheSize=32m -Dorg.terracotta.quartz.skipUpdateCheck=true -XX:MaxMetaspaceSize=128m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC"
fi

Defining Red5 Pro as a Service

To allow for ease of startup/shutdown of Red5 Pro, in addition to automatically starting the service on server reboot, you will want to add an init.d script for Red5 Pro.

To begin, create a red5pro file in init.d:

$ sudo touch /etc/init.d/red5pro

You can copy and paste the following into the red5pro file using your editor of choice:

#!/bin/sh
### BEGIN INIT INFO
# chkconfig: 2345 85 85
# description: Red5 Pro streaming server
# Provides:          Red5 Pro
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Red5Pro
# processname: red5
### END INIT INFO

PROG=red5
RED5_HOME=/usr/local/red5pro
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid

start() {
  # check to see if the server is already running
  if netstat -an | grep ':5080'; then
    echo "Red5 is already started..."
    while netstat -an | grep ':5080'; do
      # wait 5 seconds and test again
      sleep 5
    done
  fi
  cd ${RED5_HOME} && ./red5.sh &
}

stop() {
  cd ${RED5_HOME} && ./red5-shutdown.sh
}

case "$1" in
  start)
    start
    exit 1
  ;;
  stop)
    stop
    exit 1
  ;;
  restart)
    stop
    start
    exit 1
  ;;
  **)
    echo "Usage: $0 {start|stop|restart}" 1>&2
    exit 1
  ;;

esac

Make the file executable:

$ sudo chmod 777 /etc/init.d/red5pro

Configure Red5 Pro to Automatically Start on Boot/Reboot

Run the following commands to configure the Red5 Pro service to start on server startup:

$ sudo /usr/sbin/update-rc.d red5pro defaults
$ sudo /usr/sbin/update-rc.d red5pro enable

For CentOS:

$ sudo systemctl daemon-reload
$ sudo systemctl enable red5pro.service

Starting / Stopping

The Red5 Pro Server can now be started by issuing:

$ sudo /etc/init.d/red5pro start

To stop the Red5 Pro Server from running (note, it takes approximately 30 seconds for the server to fully shut down):

$ sudo /etc/init.d/red5pro stop

Additionally, you can restart the Red5 Pro Server by issuing:

$ sudo /etc/init.d/red5pro restart

Security

The following Inbound ports need to be open on your server/firewall for Red5 Pro features to work:

Port Description
22 SSH
5080 default web access of Red5 Pro
1935 default Red5 Pro RTMP port
8554 default RTSP port
6262 websockets (for second screen and HLS)
8088 second screen client registry

Ports required for WebRTC server using SSL:

Port Description Protocol
22 SSH TCP
80 modified web access of Red5 Pro TCP
443 standard HTTPS port TCP
1935 default Red5 Pro RTMP port TCP
8554 default RTSP port TCP
6262 websockets for HLS TCP
8081 websockets for WebRTC TCP
8083 secure websockets for WebRTC TCP
40000-65000 TURN/STUN/ICE port range UDP

Verifying Red5 Pro is Running

Once you have started the Red5 Pro Server, you can verify that it is running and available by visiting your instance at port 5080.

Open a web browser and navigate to http://__your server ip__:5080 (like http://127.0.0.0:5080)

To not publicly expose the default web access at port 5080, you can do either of the following:

Red5 Pro WebRTC

Red5 Pro Server Release 2.0.0 (WebRTC Beta2) includes WebRTC support and front-end integration of the Red5 Pro HTML5 SDK.

WebRTC (Web Real-Time Communication) is supported by the Chrome, Firefox and Opera browsers on desktop. In addition, the Chrome browser on Android supports WebRTC. Safari and Internet Explorer do not support WebRTC (but reportedly, Microsoft Edge does).

Broadcasting/subscribing of WebRTC to WebRTC, WebRTC to HLS, WebRTC to Flash, and Flash to WebRTC are all supported.

Subscribing to a WebRTC publisher using the Red5 Pro Android or iOS SDK client is supported. In addition, subscribing with WebRTC to a stream published with Red5 Pro Android or iOS SDK client is supported.

WebRTC Broadcaster/Subscriber combinations supported, in a nutshell:

  • WebRTC <==> WebRTC
  • WebRTC <==> Flash
  • WebRTC <==> Red5 Pro iOS SDK
  • WebRTC <==> Red5 Pro Android SDK
  • WebRTC ==> HLS

WebRTC Overview

WebRTC runs on the standard HTTPS port (443). To run Red5 Pro WebRTC server you need to have a valid SSL Certificate for a registered URL. Red5 Pro with SSL walks you through setting up the certificate on your server. Additionally, as with other Red5 Pro server distributions, you will need to install Java (minimum version 8.0).

If you are running the server, without an SSL cert, on your local machine or on a server:

  1. You will be able to publish/subscribe locally (between browsers).
  2. You will be able to subscribe to a stream that is being published from localhost (e.g.: http://localhost:5080/live/broadcast.jsp) from a device within the same network (pointing to the IP address of your machine, not to localhost). To subscribe from a mobile device, either via browser on Android, or via SDK client on iOS or Android, the device must be on the same Wifi network as the desktop.
  3. You will not be able to publish via a WebRTC client that is not local to the machine.

How to modify default ports

Some firewalls or even service providers may block some of the Red5 Pro default ports, so you may want to modify those. There are two files that allow you to define the ports that Red5 Pro uses: {red5pro}/conf/red5.properties, and {red5pro}/conf/red5pro-activation.xml

red5.properties file : RTMP, HTTP, Websockets

To modify the default RTMP port, edit {red5pro}/conf/red5.properties RTMP section:

# RTMP
rtmp.host=0.0.0.0
rtmp.port=1935

To modify the default HTTP (or HTTPS) port, edit the HTTP section:

# HTTP
http.host=0.0.0.0
http.port=5080
https.port=5443

To modify the default Websockets port, edit the Websocket section:

# WebSocket
ws.host=0.0.0.0
ws.port=8081

Note: this is also where you define secure websockets (wss) if you need them.

red5pro-activation.xml file: RTSP, secondScreen, websocket (for HLS)

Modify the configuration bean if you wish to modify any of the default ports for RSTP, WebSockets for HLS, or Second Screen:

<bean name="configuration" id="configuration" class="com.red5pro.activation.Red5ProConfiguration">
<property name="rtsp" value="true"/>
<property name="secondscreen" value="true"/>
<property name="websockets" value="true"/>
<property name="rtspPort" value="8554"/>
<property name="secondScreenPort" value="8088"/>
<property name="websocketPort" value="6262"/>
<property name="enableRecording" value="true"/>
</bean>