September 20, 2017

LiveSwitch and FreeSWITCH - Part 2

By Anton Venema

This is Part 2 of a series. Read Part 1 here .

In Part 1 of this series, we built a web application with LiveSwitch that creates MCU, SFU, and peer connections, all at the same time, and all in the same app.

Part 2 (today) is going to cover the integration of FreeSWITCH and the LiveSwitch SIP connector to bridge in VoIP phones and the traditional telephone network (PSTN / POTS). FreeSWITCH

To start, you’re going to need FreeSWITCH installed somewhere. If you haven’t already, install the LiveSwitch SIP connector somewhere as well that can access both the LiveSwitch gateway (over HTTP/S) and FreeSWITCH (over SIP). The SIP connector is going to act as a bridge between LiveSwitch and SIP signalling.

The rest is just configuration.

Configuring the LiveSwitch SIP Connector

The online docs have a very detailed configuration guide that covers the configuration options available in the SIP connector. We’re going to hit the highlights here.

The installer should have prompted you for the LiveSwitch gateway URL, license key, and SIP registration details, but you can verify them by checking the config file:

?
1
2
3
4
5
6
7
8
9
<connector logLevel= "Info" gatewayUrl= "--my.gateway--" sharedSecret= "--secret--" >
     <license key= "--license--" />
</connector>
<sip serverPort= "5060" >
     <registration domain= "--my.domain--" username= "user" password= "1234" />
     <dialPlan>
         <mappings />
     </dialPlan>
</sip>

The <connector /> section covers your high-level configuration for the service itself, including your gateway URL, shared secret (for authorization - it should match the shared secret in the gateway configuration), and license key.

The <sip /> section covers your SIP registration details and a <dialPlan> to map incoming calls to LiveSwitch application/channel IDs.

In this case, your <registration /> domain should point to your FreeSWITCH server, and your username/password should be valid for that FreeSWITCH installation.

Once you’ve plugged in your server details, it’s time to set up your dial-plan.

There are two ways to configure it - static or dynamic. The static configuration is easy. Just add mappings between inbound SIP identifiers (the “to user”) and application/channel IDs.

?
1
2
3
4
5
<dialPlan>
     <mappings>
         <add toUser= "18001234567" applicationId= "my-app-id" channelId= "my-channel-id" />
     </mappings>
</dialPlan>

While this is simple, it’s also somewhat limited, since it forces you to use a unique inbound number for each unique application/channel ID, and requires you to code them into the configuration in advance.

The more powerful approach is to use a dynamic configuration, which involves setting up a simple web hook :

?
1
<dialPlan webHookUrl= "--my.web.hook--" />

If a web hook is provided, then an inbound call will trigger a simple HTTP request to the provided URL. The entire SIP message is included in this request, with the expected response containing the application/channel ID to target.

Since all the SIP headers are included in this request, you can combine a FreeSWITCH IVR with custom SIP header actions such that a single inbound number can service multiple LiveSwitch applications and channels.

That’s it!

Make sure that FreeSWITCH, the LiveSwitch gateway, media server, and SIP connector are all running, and then dial-in to the “toUser” number provided by your static or dynamic dial-plan.

Fire up the web application from Part 1 using the same application/channel ID as the dial-plan, open an MCU connection, and chat it up!

As always, if you have any questions or comments, we would love to hear from you . If you need help setting up FreeSWITCH or configuring it to meet your needs, our professional services team is standing by to help.

LiveSwitch Whitepaper-1

Anton Venema

As Frozen Mountain’s CTO, Anton is one of the world’s foremost experts on RTC solutions, as well as the technical visionary and prime architect of our products, IceLink and WebSync, and our custom solutions. Anton is responsible for ensuring that Frozen Mountain’s products exceed the needs of today and predict the needs of tomorrow.

RSS Feed

Subscribe Now

Looking for Something in Particular?

    Recent posts