Call Us Today! 877.742.2583




Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The external Erlang application controls the FreeSWITCH instance by sending messages to it (e.g., to check status, originate calls, register to receive events, execute applications).

Outbound mode

The FreeSWITCH instance is calling the external Erlang application from a dialplan extension to process certain system events, such as handling a particular call. If a use case can be handled in a dialplan An <dialplan> <extension> can open a connection to an external application (running locally or on a remote host), and then forward all <system events> related to incoming calls to this extension. That is, if scenario can be handled in an extension, then it can be processed by (, and the workload offloaded to ) an external application (using the Event Socket Library).

When an incoming call traverses the dialplan, and matches an extension that calls an outbound socket, the call gets parked first. System events relating to the call are then sent from FreeSWITCH to the specified Erlang process on the specified node. The process can either be

  • a pre-defined one (a registered process),
  • a dynamic one (a spawned process) or a
  • dynamically returned process (send a message to a registered process, it returns a pid PID that can either be newly spawned or already existent).

...

Code Block
languagexml
title<conf_dir>/autoload_configs/modules.conf.xml
linenumberstrue
<configuration name="modules.conf" description="Modules">
  <modules>
    <!-- ... other modules ... -->
    <load module="mod_erlang_event"/>
    <!-- ... other modules ... -->
  </modules>
</configuration>

Step 2. Configure

mod_erlang_event's configuration file (<conf_dir>/autoload_configs/erlang_event.conf.xml) is very similar to the one for mod_event_socket, but

...

some parameters are

...

different

...

. See Configuration Parameters below

...

.

Expand
titleDefault configuration for vanilla installations
:
(click to expand)


Code Block
languagexml
title<conf_dir>/autoload_configs/erlang_event.conf.xml
linenumberstrue
<configuration name="erlang_event.conf" description="Erlang Socket Client">
  <settings>
    <param name="listen-ip" value="0.0.0.0"/>
    <param name="listen-port" value="8031"/>
    <!-- Specify the first part of the node name
         (the host part after the @ will be autodetected)
         OR pass a complete nodename to avoid autodetection
         eg. freeswitch@example or freeswitch@example.com.
         If you pass a complete node name, the 'shortname' parameter has no effect. -->
    <param name="nodename" value="freeswitch"/>
    <!-- Specify this OR 'cookie-file' or $HOME/.erlang.cookie will be read -->
    <param name="cookie" value="ClueCon"/>
    <!-- Read a cookie from an arbitary erlang cookie file instead -->
    <!--<param name="cookie-file" value="/$${temp_dir}/erlang.cookie"/>-->
    <param name="shortname" value="true"/>
    <!-- in additon to cookie, optionally restrict by ACL -->
    <!--<param name="apply-inbound-acl" value="lan"/>-->
    <!-- alternative is "binary" -->
    <!--<param name="encoding" value="string"/>--> 
    <!-- provide compatability with previous OTP release (use with care) -->
    <!--<param name="compat-rel" value="12"/> -->
  </settings>
</configuration>


Step 3. Restart FreeSWITCH

Use sudo service freeswitch restart where SystemD is systemd  is used (reloadxml won't be enough).

...

The configuration parameters from mod_erlang_event.c:1232:

<param name="listen-ip" value="0.0.0.0"/>

Specify the IP address of the server where the Erlang application is located.

<param name="listen-port" value="8031"/>

Note

By default, mod_erlang_event listens on a different port (8031) than mod_event_socket (8021).

<param name="cookie" value="ClueCon"/>

Instead of a password in mod_event_socketmod_erlang_event uses a cookie.

Tip

See Erlang Reference ManualDistributed Erlang chapter,  13.7 Security section for more on cookies.

<param name="cookie-file" value="?"/>

Note
titleHelp Needed - previously undocumented

I assume that value is a path, but this theory needs testing.

<param name="nodename" value="freeswitch"/>

<param name="shortname" value="true"/>

From the Erlang Reference ManualDistributed Erlang chapter,  13.2 Nodes section (with minor edits):

...

  • with shortname enabled, the full nodename is 'freeswitch@example'
  • with shortname disabled, it will  be 'freeswitch@example.com' instead.

How to set a custom name?

To force the nodename, specify the whole name (e.g., 'freeswitch@example.com') in the 'nodename' tag; mod_erlang_event will not try to guess what to call the node.

Note

Erlang nodes with a short name can only talk to other nodes with a short name, and the same thing applies for nodes with long names.

<param name="encoding" value="string"/>

The encoding  parameter indicates if you would prefer events to be encoded as Erlang binaries or as Erlang strings. Binaries tend to be faster and consume less memory, but strings can be easier to work with.

<param name="compat-rel" value="12"/>

From the vanilla erlang_event.conf.xml: "provide compatibility with previous OTP release (use with care)".

<param name="apply-inbound-acl" value="lan"/>

Just as with mod_event_socket, provide additional restrictions via ACLs besides the cookie .

Undocumented parameters

The parameters below haven't been documented, but one can guess their functions. See their implementation in mod_erlang_event.c:1232.

...