Using FreeSwitch
I'm completely new to FreeSwitch, so I'm documenting my experience of trying to get it to do something useful, in the hopes that this will help others coming at it for the first time too.
This refers to FreeSwitch version 1.10.6 installed under Devuan 3 Beowulf.
Documentation
FreeSwitch documentation is awful. Information is available, and a lot of it is on FreeSwitch's website, but finding anything is a nightmare; the indexing is terrible. There's certainly no "start here and we'll lead you through the basics and point you at more so you can then explore on your own".
Here are some pointers to (external to this wiki) links of useful stuff I've found:
- A diagrammatic life cycle of a call
- A list of call states with no explanation about them
- Channel states with descriptions
- A list of FreeSwitch variables
-
- FreeSwitch uses XML for its dialplans
- FreeSwitch's command line interface
- Commands you can call from dialplans
- Calling API commands from a dialplan
- A list of modules and ways of creating dialplans
- Doing multi-tenant with FreeSwitch
- FreeSwitch's SIP stack is called "Sofia"
- Some extremely terse documentation about configuration parameters
- Sofia Request headers
- Sofia Response headers
- Gateways (trunks)
- How to connect to FS from something else
- What you can do once connected
- Talking to the Event Socket with Perl
-
-
- Configuation with lua
-
-
- CDRs via ODBC
- FreeSwitch High Availability
-
- Section 2.1 lists the categories you can specify with "events plain XXX" etc.
-
- Logging the events (but, not yet, logging the dialplan actions)
- Databases in FreeSwitch
- FreeSwitch keeps its internal configuration in a database
- Dialplan database operations
- A smaller page with a later datestamp
-
- Queries (not available with standard Debian packages)
- Using databases with lua for dialplan apps, directories, and something on-the-fly
- FreeSwitch Directory in database via lua
NAT
If you've done anything with SIP previously, you probably know that NAT can be a problem that needs to be dealt with (but there are ways to do that).
FreeSwitch has found a way to make NAT even more of a problem than usual.
Useful bits and pieces
- How to dial out to a SIP server with credentials in the dialplan (no pre-defined gateway needed)
<action application="bridge" data="{sip_auth_username=${sip_user},sip_auth_password=${sip_pass}}sofia/GW/${destination_number}@${SIP_server}"/>
- That will dial to ${destination_number} via ${SIP_server} using credentials ${sip_user} and ${sip_pass}
- You need to have a gateway profile named GW, but it doesn't need to have anything defined in it
- You might need to do
<action application="set" data="effective_caller_id_number=${sip_user}"/>
just beforehand, depending on how fussy the remote server is
Message waiting (MWI)
FreeSwitch can register as a client to a SIP server (ie: pretend to be a telephone), and it is far more capable in this regard than Asterisk is.
Asterisk can REGISTER (to receive calls), and it can send INVITEs (to place calls), although the latter is a bit buggy because it fails if you have a ! or a : in the SIP password.
However, that's it - Asterisk can't do anything else - it has no clue about presence, it can't do message waiting, it can't send hold or resume commands, and it can't send refer commands (for transfers).
FreeSwitch can do all of the above, albeit with certain caveats.
The biggest one for me is that FreeSwitch can SUBSCRIBE for presence Events, and it works. It can also SUBSCRIBE for message-summary Events (MWI), and that works. It completely ignores unsolicited MWI, which is the standard way in which telephones and PBXs tend to do it.
If your PBX won't accept a SUBSCRIBE for message-summary Events (which Bicom PBXware doesn't, for example) then you can't get FreeSwitch and the PBX to exchange MWI information.
The following is not yet correct.
The answer is to make a surprisingly small change to the FreeSwitch source code and recompile it.
Edit the file src/mod/endpoints/mod_sofia/sofia.c
Find the section containing:
if (!sofia_private || zstr(sofia_private->gateway_name)) { if (profile->debug) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Gateway information missing Subscription Event: %s\n", sip->sip_event->o_type); } goto error; }
Change this to:
if (!sofia_private || zstr(sofia_private->gateway_name)) { if (profile->debug) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Gateway information missing Subscription Event: %s\n", sip->sip_event->o_type); } if (strcasecmp(sip->sip_event->o_type, "message-summary")) goto error; }
FreeSwitch will now continue to output the message Gateway information missing Subscription Event: message-summary when an unsolicited MWI NOTIFY comes in, but now it will fire a NOTIFY_IN event which you can handle (for example with an Event hook).
Go up
Return to main index.