Installation

We would like to remind you that Mona is licensed under the GNU General Public License, so MonaBase can’t be linked with any closed source project..

Binaries

A 32-bit Windows zipped package is provided to quickly test MonaServer.

We recommend you to clone the github version from the sources for production use.

If you download the Windows 32-bit binary, then you can skip down to the Configurations section of this document.

Note

In order to use it you need the C++ Redistributable Packages for Visual Studio 2013.

Download

You can download the entire sources with zipball or use a GIT client to clone the following address: https://github.com/MonaSolutions/MonaServer.git.

Build

The Mona source code is cross-platform. Supported OS are :

  • Windows (minimum XP)
  • All Linux OS
  • FreeBSD
  • OS-X

If you need to target a specific platform or if you encouter problems during the build please ask us on the forum.

Dependencies and requirements

Mona has the following dependencies :

Note

LuaJIT is an alternative to the official LUA interpreter. It works faster than LUA essentially because it compiles the LUA code to machine code during execution (see LuaJIT performance about performance comparison).

As C++11 is used in MonaServer you need to install a compiler which is compatible. At least gcc/g++ 4.8.2 on Linux/FreeBSD/OS-X and VS 2013 on Windows.

LuaJIT installation

For several reasons some functionalities of LUA 52 are not allowed by default in luajit (like # or pairs()) so we recommend you to compile luajit by yourself and set the DLUAJIT_ENABLE_LUA52COMPAT option.

  • First download the latest release of LuaJIT (here with git) :
    git clone http://luajit.org/git/luajit-2.0.git
    
  • Then set the DLUAJIT_ENABLE_LUA52COMPAT option :
    • On Linux just search DLUAJIT_ENABLE_LUA52COMPAT in src/Makefile and uncomment the line
    • On Windows search the line beginning with @set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE in src/msvcbuild.bat. Then add the /DLUAJIT_ENABLE_LUA52COMPAT option
  • Finally you can compile luajit (make or src/msvcbuild.bat)

Note

On Linux just run sudo make install to install luajit on the system.

Windows Build

First follow the LuaJIT installation steps.

Visual Studio 2013 solution and project files are included. It searches external libraries in External/lib folder and external includes in External/include folder in the root Mona folder. So you must put OpenSSL and LuaJIT headers and libraries in these folders. You can find OpenSSL binaries for windows on Win32OpenSSL.

Unix (Linux/OS-X) Build

First follow the LuaJIT installation steps.

If your Unix system includes a package manager you can quickly install OpenSSL. The package is usually named libssl-dev (or openssl-devel).

Warning

  • You need to use the -dev (or -devel) version to get the header files required during Mona compilation,
  • Don’t use clang/llvm on OS-X, use rather gcc.

To build Mona:

$ make

To clean:

$ make clean

Amazon EC2 AMI Build

First follow the LuaJIT installation steps.

Create a standard EC2 AMI with a new security group. Open up all UDP and at least TCP Ports 1935 in the Security Group.

Connect to the AMI and execute the following script:

sudo -s
yum -y groupinstall "Development Tools"
yum -y groupinstall "Development Libraries"
yum -y install make
wget https://github.com/MonaSolutions/MonaServer/archive/master.zip
unzip Mona-master.zip
cd Mona-master
make
sudo ./MonaServer --daemon

Raspberry PI (armv61) Build

You need to install a distribution where gcc 4.8.2 is available. For now we have only found Raspbian upgraded to the distribution jessie. Here is the protocol to install it correctly :

sudo aptitude update
sudo aptitude dist-upgrade
sudo rpi-update
reboot

Configurations

MonaServer is statically configured by an optional configuration MonaServer.ini file to put in the installation folder. Possible configurations are :

  • host : address like it will be seen by clients and other servers, this option is mandatory to make working all redirection features in multiple server configuration (see Scalability and load-balancing).
  • socketBufferSize : allows to change the size in bytes of sockets reception and sending buffer. Increases this value if your operating system has a default value too lower for important loads.
  • threads : indicates the number of threads which will be allocated in the pool of threads of Mona. Usually it have to be equal to (or greather than) the number of cores on the host machine (virtual or physic cores). By default, an auto-detection system tries to determinate its value, but it can be perfectible on machine who owns hyper-threading technology, or on some operating systems.

[application]

  • dir : Directory containing data and www.

[servers]

  • port : port to receive incoming server connection (in a multiple servers configuration, see Scalability and load-balancing for more details). If you don’t configure this port, MonaServer cannot establish a connection with it.

Warning

The exchange between servers is done in a unencrypted TCP way, so to avoid an attack by this incoming end point the servers.port should be protected by a firewall to allow just a connection by an other server and nothing else.

  • targets : list of MonaServer addresses (separated by semicolons) to connect on start-up. When the server will start, it will try to etablish a connection to these addresses every 10 seconds (see Scalability and load-balancing for more details). Each token can include arguments through as a query url form:
[servers]
targets=192.168.0.2:1936?name=master&arg=val;192.168.0.3:1936

It will create dynamic properties on server object (see server object description of “Server application, api” page for more details).

function onServerConnection(server)
  if server.name=="master" then -- true here just for 192.168.0.2:1936 server
    NOTE("server master arg = "..server.arg) -- displays here "server master arg = val"
  end
end

[RTMFP]

  • port : 1935 by default (RTMFP server default port), it is the port used by MonaServer to listen incoming RTMFP requests.
  • keepaliveServer : time in seconds for periodically sending packets keep-alive with server, 15s by default (valid value is from 5s to 255s).
  • keepalivePeer : time in seconds for periodically sending packets keep-alive between peers, 10s by default (valid value is from 5s to 255s).

[RTMP]

  • port : 1935 by default (RTMP server default port), it is the port used by MonaServer to listen incoming RTMFP requests.

[HTTP]

  • port : 80 by default (HTTP server default port), it is the port used by MonaServer to listen incoming HTTP requests.
  • timeout : 7 by default, it is the maximum time before server kills the connection when no data as been received.
  • index : the default index file of HTTP protocol, if it is specified it will redirect each connection to this index.

[WebSocket]

  • timeout : 120 by default, it is the maximum time before server kills the connection when no data as been received.

[logs]

  • directory : directory where the log files are written (MonaServer/logs by default).
  • name : name of log files (log by default).
  • rotation : number of files to keep in logs directory

Note

Maximum size of a file is 1Mb.

Sample of MonaServer.ini

;MonaServer.ini
socketBufferSize = 114688
[RTMFP]
port = 1985
keepAlivePeer = 10
keepAliveServer = 15
[logs]
name=log
directory=C:/MonaServer/logs

If this configuration file doesn’t exist, default values are used.

Launch

Start

MonaServer includes some argument launch options, but by default MonaServer is optimized for a production running. Command-line options are useful during development and test usage. To get full descriptions about the launch arguments start MonaServer with /help argument on Windows or –help on Unix system.

Otherwise, simply start the MonaServer application with administrative rights.

You can also start it as a Windows service:

MonaServer.exe /registerService [/displayName=MonaServer /description="Open Source RTMFP Server" /startup=automatic]

Or an Unix daemon:

sudo ./MonaServer --daemon [--pidfile=/var/run/MonaServer.pid]

Usage

Flash client connects to MonaServer by the classical NetConnection way:

_netConnection.connect("rtmfp://localhost/");

Here the port has its default value 1935. If you configure a different port on MonaServer you have to indicate this port in the URL (after localhost, of course).

The path used allows you to connect for your desired Server Application.

_netConnection.connect("rtmfp://localhost/myApplication");

To learn more, read the Server Application or Samples pages.