Last Updated: February 25, 2016
·
5.023K
· mattisdada

Installing Asterisk 11 with WebRTC / Websockets for Mandriva

This is a self guide for installing Asterisk 11 with WebRTC / Websockets for Mandriva. The instructions given here should work flawlessly for any distro as everything is built from source. (Example, Ubuntu, Gentoo, Mint, CentOS, RHEL, etc)

This is assuming a fresh install.

Install lib dependancies. Not all of these are required for every install, but are very commonly required. (replace urpmi with equivlent [ie, apt-get install, yum, etc])

# making sure we have the mirrors we need. optional 
urpmi.addmedia --distrib --mirrorlist '$MIRRORLIST'

urpmi wget gcc gcc-c++ ncurses-devel libxml2-devel sqlite-devel libuuid-devel openssl-devel mysql lib64mysql-devel git lib64uuid-devel  sqlite3-devel

Change directories to our source folder

cd /usr/local/src

Download the required sources for Asterisk & pre-reqs

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz

Extract sources (replace X/Y with the version numbers, you can use the tab feature to quickly auto-complete)

tar -zxvf libpri-1.X.Y.tar.gz
tar -zxvf dahdi-linux-complete-current.tar.gz
tar -zxvf asterisk-11-current.tar.gz

Next we are going to build out the pre-req's for Asterisk (DAHDI, LibPRI). Each of these lines assume you have the current directory set as /usr/local/src.

If you run into compiling issues, the most likely reason is you have missing libaries / compilers. Googling the error will tell you what you require then use urpmi (or system equivalent) to download & install

DAHDI:

cd dahdi-linux-complete-2.X.Y+2.X.Y
make
make install
make config 

LibPRI:

cd libpri-1.X.Y
make
make install    

Optional (if you want Websockets to work this is required)

SRTP

wget http://srtp.sourceforge.net/srtp-1.4.2.tgz
tar zxvf srtp-1.4.2.tgz
cd srtp
./configure CFLAGS=-fPIC
make
make install

Now to actually installing Asterisk 11

cd /usr/local/src/asterisk-11.X.Y
./configure

Note: If you have missing dependencies and need to run configure again, I recommend running make distclean beforehand. Trust me, a lot less headaches

Now it's time to pick and choose what features you need in your installation. I do recommend installing the MySQL features, even if you don't immediately intend to use it. I find most people end up using it in some capacity.

make menuselect

To have Websockets work you must enable STRP (Resources -> reset_strp)

Once you have finished picking what features you want all we have to do now is compile and install

make
make install

Optional Installing sample config files

make samples

Installing Initialization Scripts and Log Rotate

make config
make install-logrotate

Next we have to make sure Websockets can connect to our server.

Create or edit /etc/asterisk/http.conf

;http.conf
[general]
enabled=yes
bindaddr=0.0.0.0 ; Or replace this with your IP address for better security
bindport=8088

Create or edit /etc/asterisk/sip.conf (please note this is just an example, I stole it from SipJS to make everyone's lives easier than my messy config)

;sip.conf
[general]
realm=127.0.0.1 ; Replace this with your IP address
udpbindaddr=127.0.0.1 ; Replace this with your IP address
transport=udp

[1060] ; This will be WebRTC client
type=friend
username=1060 ; The Auth user for SIP.js
host=dynamic ; Allows any host to register
secret=password ; The SIP Password for SIP.js
encryption=yes ; Tell Asterisk to use encryption for this peer
avpf=yes ; Tell Asterisk to use AVPF for this peer
icesupport=yes ; Tell Asterisk to use ICE for this peer
context=default ; Tell Asterisk which context to use when this peer is dialing
directmedia=no ; Asterisk will relay media for this peer
transport=udp,ws ; Asterisk will allow this peer to register on UDP or WebSockets
force_avp=yes ; Force Asterisk to use avp. Introduced in Asterisk 11.11

[1061] ; This will be the legacy SIP client
type=friend
username=1061
host=dynamic
secret=password
context=default

And that should have you up and running. You can use sipml5 or SIPJs to test Websocket connections and VOP Nano to test SIP connection.

Your websocket URL is:

ws://<ip address>:8088/ws