Wiki -VoIP Topics

Web SIP client for Asterisk


Setup a browser web sip phone for Asterisk

The Mizu web phone can be used as a web sip client for Asterisk (and all it's clones such as FreePBX) so you can make call trough Asterisk from any browser.
Think about it as a normal SIP softphone, but with the following differences:

  • you need to deploy it to your web server (just copy the webphone folder to your website, change a few settings such as your SIP server address and refer to it from your html)
  • runs from browsers, so users will not have to install any softphone
  • settings can be provided in a file hosted on your webserver (webphone_api.js)
  • you can also implement any kind of logic or create your custom web sip client solution using its JavaScript API

A public IP address is highly recommended to avoid complicated NAT scenarios.

Setup Asterisk with a webphone extension

Configure an extension exactly the same way as you do for other endpoints such as a softphone.
Go to the directory where the configuration files are located:
    cd /etc/asterisk

Configure a Web SIP channel for Asterisk 11 and previous
You need to use chan_sip.
In file sip.conf:

[general]
context=default

[7001]
type=friend
context=from-internal
host=dynamic
secret=xxx
disallow=all
allow=ulaw,opus,vp8,h264
dtmfmode=info
nat=yes


More help:     
    https://www.asteriskguru.com/tutorials/asterisk_voip_ipphone.html
    https://www.voip-info.org/wiki/view/Asterisk+config+sip.conf

Configure a Web SIP channel for Asterisk 12 and beyond
New versions of Asterisk uses chan_pjsip by default.
In file pjsip.conf:

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

[7001]
type=endpoint
context=from-internal
disallow=all
allow=ulaw,opus,vp8,h264
dtmfmode=info
auth=7001
aors=7001
nat=yes

[7001]
type=auth
auth_type=userpass
password=xxx
username=7001
nat=yes

[7001]
type=aor
max_contacts=1


More help:
    https://wiki.asterisk.org/wiki/display/AST/Registering+Phones+to+Asterisk
    https://zadarma.com/en/support/instructions/asteriskpjsip/

Start or restart Asterisk
Start:
    asterisk -cvvvvv
Restart:
    asterisk -rx "core restart now"
    asterisk -rvvvvv


Deploy the SIP Web Phone for Asterisk
Copy the webphone folder to your webserver and refer it from your html (for example from your main page) or use one of the html's from the webphone folder in your browsers by specifying its exact URL.
Note1: You must set the webphonebasedir parameter if the html from where you refer to the webphone is not inside the webphone directory!
Note2: You might have to enable the .jar, .exe, .swf, .dll, .so and .dylib mime types in your webserver if not enabled by default (these files might be used in some circumstances depending on the client OS/browser).
Note3: If you wish to use (also) the WebRTC engine then your site should be secured (HTTPS with a valid SSL certificate). Latest Chrome and Opera requires secure connection for both your website (HTTPS) and websocket (WSS). If your website doesn’t have an SSL certificate then we can host the webphone for you for free.

Alternatives:
o    You can also test it without a webserver by launching the html files from your desktop, although some engines might not work correctly this way
o    You can also test it by using the online demo hosted by Mizutech website, but in this case you will not be able to change the configuration (you can still set any parameters from the user interface or from URL)
For more details see the webphone documentation.

Configure the Web Phone for Asterisk:
In the webphone_config.js enter the following settings:
webphone_api.parameters = {
                    serveraddress: 'ASTERISK_IP_OR_DOMAIN',
                    username: '7001',
                    sippassword: 'xxx',
                    loglevel: 5,
                 };


Note: username/password can be also requested at runtime and entered by the enduser.

Launch the web client:
Launch your browser and open the html from where you are referring to the webphone or one of the html's from the webphone directory.
For example: http://yourdomain.com/webphone/techdemo_example.html
The web sip client should register automatically and you are now ready to:

  • accept incoming calls
  • make calls to other softphones or outbound calls to landline/mobile (if your Asterisk has an outbound channel)
  • send chat, make video calls, file transfer and others
  • implement your custom app logic using the webphone JavaScript API

Troubleshooting: If the webphone can't register/connect or cannot make calls, first find out if the problem is with Asterisk or with the webphone.
Make a test call with some third-party softphone (for example X-Lite) and if this doesn't work, then the problem is with Asterisk setup. Otherwise the problem is with the webphone configuration.

For Asterisk:

  • watch the CLI, check the logs
  • make sure to set the CLI verbosity level to at least three while you reboot the phone
  • Asterisk Troubleshooting: www.voip-info.org/wiki/view/How+To+Debug+and+Troubleshoot+VOIP
  • PJSIP Troubleshooting: https://wiki.asterisk.org/wiki/display/AST/Asterisk+PJSIP+Troubleshooting+Guide

For Webphone:

  • make sure that the loglevel is set to 5 and check the logs from the help menu
  • have a look at the webphone documentation (especially the FAQ section as that discusses some common issues)
  • if still doesn't work send the logs to Mizutech support

Note about WebRTC:
To take full advantage of the new WebRTC technologies, you can use a WebRTC to SIP gateway or configure the built-in WebRTC in your Asterisk.

 

Web SIP client for Asterisk