Building a web-based phone is easy enough with asterisk and jssip. At the time of writing this, I was using asterisk 11.6 (LTS) and jssip 0.6.21.
My web application is hosted on a local webserver that resides on the same server as asterisk. Because of that, it is not possible to tell asterisk to bond on port 80 or 443 for its internal websocket server. So I've configured asterisk to bond on port 8088. But having a webapp that wants to communicate on such a port will not work if the clien is behind a firewall that blocks outside access to non standard ports. So I've configured Apache to proxy websocket connections to a chosen URL to the asterisk server on the local host.
- Make sure res_srtp is loaded in asterisk (you may need to install libsrtp and rebuild asterisk). This is absolutely needed for webrtc to work.
- Enable websockets in asterisk http.conf
[general] enabled=yes bindaddr=127.0.0.1 bindport=8088
- Make a proxy entry in apache for wss://www.dumaisnet.ca/pbxws -> ws://127.0.0.1:8088/ws
<VirtualHost *:443> SSLEngine On ... ServerName www.dumaisnet.ca <Location /pbxws> ProxyPass ws://127.0.0.1:8088/ws nocanon ProxyPassReverse ws://127.0.0.1:8088/ws </Location> </VirtualHost>
- Generate DTLS certificates for asterisk
mkdir /folder.to.keys cd <asterisk src directory>/contrib/scripts ./ast_tls_cert -C wwwdumaisnet.ca -O "Dumaisnet" -d /folder.to.keys
- Configure a SIP peer in sip.conf
transport=ws avpf=yes videosupport=no encryption=yes icesupport=yes directmedia=no force_avp=yes dtlsenable=yes dtlsverify=no dtlscertfile=/folder.to.keys/asterisk.pem dtlsprivatekey=/folder.to.key/asterisk.pem dtlssetup=actpass