Guides

Configure FreeSWITCH

SIP.js has been tested with FreeSWITCH 1.6.14 without any modification to the source code of SIP.js or FreeSWITCH. Later versions of FreeSWITCH will require similar configuration. Letsencrypt is required for wss.

System Setup

FreeSWITCH and SIP.js were tested using the following setup:

Required Packages

Install the following dependencies:

Using YUM, all dependencies can be installed with:

1
2
3
4
yum install git autoconf automake libtool gcc-c++ yasm \
libuuid-devel zlib-devel libjpeg-devel ncurses-devel \
openssl-devel sqlite-devel libcurl-devel speex-devel \
ldns-devel libedit-devel lua-devel libsndfile-devel

Opus needs to be downloaded and installed from FreeSWITCH. The packages are linked below along with the command to download and install the packages on CentOS.

1
2
3
wget http://files.freeswitch.org/yum-1.6/7/x86_64/opus-1.1-1.el7.centos.x86_64.rpm \
http://files.freeswitch.org/yum-1.6/7/x86_64/opus-devel-1.1-1.el7.centos.x86_64.rpm \
&& yum localinstall opus*

Install FreeSWITCH

FreeSWITCH recommends using the latest version of FreeSWITCH from the FreeSWITCH git repo. This example uses FreeSWITCH tag v1.6.14.

Configure FreeSWITCH

FreeSWITCH 1.6.14 is configured to work with SIP.js by default. The default configuration location is /usr/local/freeswitch/conf.

Start FreeSWITCH: /usr/local/freeswitch/bin/freeswitch.

Configure SIP.js

SIP.js works with FreeSWITCH without any special configuration parameters. The following UA is configured to connect to a default FreeSWITCH configuration. Replace 127.0.0.1 with the IP address of your FreeSWITCH server.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var config = {
  // Replace this IP address with your FreeSWITCH IP address
  uri: '1000@127.0.0.1',

  // Replace this IP address with your FreeSWITCH IP address
  // and replace the port with your FreeSWITCH ws port
  ws_servers: 'ws://127.0.0.1:5066',

  // FreeSWITCH Default Username
  authorizationUser: '1000',

  // FreeSWITCH Default Password
  password: '1234'
};

var ua = new SIP.UA(config);

Troubleshooting

It is known that SIP.js and FreeSWITCH might not interop well if you have the following option enabled on FreeSWITCH:

1
<variable name="sip-force-contact" value="NDLB-connectile-dysfunction"/>

FreeSWITCH has a confluence article on WebRTC support.

Configure Web Socket Secure (WSS) with Letsencrypt

Browsers are more forcibly requiring secure connections to enable WebRTC features. To enable WSS to work with most modern browsers you will need a real SSL certificate, whcih can be obtained from letsencrypt for free. This guide covers the initial acquisition of the certificate for testing. Renewing the certificate or other issues are outside the scope of this guide.

Install Certbot

Cloning from source is the easiest way to get certbot running on Centos 7.

Run Certbot

To run certbot replace the example@sipjs.com email address with your email address, and the sipjs.com domin with your domain name that is pointing at this server.

Letsencrypt does not issue certificates for IP addresses, but you can use http://xip.io/ to turn your IP address into a domain address.

Note: if your domain name changes you will need to obtain a new certificate.

Install the Certificate into FreeSWITCH

Replace sipjs.com with the domain name that you used to generate the certificate.

Configure SIP.js to use a Secure Connection

SIP.js works with secure connections out of the box.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var config = {
  // Replace this IP address with your FreeSWITCH IP address
  uri: '1000@127.0.0.1',

  // Replace sipjs.com with your domain name
  // and replace the port with your FreeSWITCH wss port
  ws_servers: 'wss://sipjs.com:7443',

  // FreeSWITCH Default Username
  authorizationUser: '1000',

  // FreeSWITCH Default Password
  password: '1234'
};

var ua = new SIP.UA(config);

Troubleshooting

If the browser is silently failing to connect to FreeSWITCH securely it is most likely a bad certificate. Browsers will silently fail on this and SIP.js has no control over this.

FreeSWITCH has a confluence article on WebRTC support