freeswitch-号码连选

cd /usr/local/freeswitch/conf/sip_profile/external/
添加网关如下:
<gateway name="gw30">
<param name="realm" value="218.56.x.x"/>
<param name="username" value="xxxxxx30"/>
<param name="password" value="xxxx"/>
<param name="register" value="true"/>
</gateway>
<gateway name="gw31">
<param name="realm" value="218.56.x.x"/>
<param name="username" value="xxxxxx31"/>
<param name="password" value="xxxx"/>
<param name="register" value="true"/>
</gateway>
name属性就是网关名字
realm是对应服务器的ip地址,默认是5060端口,如果端口有变,则需要value:“218.56.x.x:port”
username,password就是用户名和密码
register就是注册,为true的时候表示需要注册
freeswitch> reload mod_sofia

网关注册成功后,我们就可以通过这个号码(又称为线路)打入打出电话了。我们可以使用如下命令快速试一下是否能通过某一条线路(如gw30)成功呼出:

freeswitch> originate sofia/gateway/gw30/1860535xxxx &echo

然后使用mod_distributor进行连选
首先,要安装该模块,进入FreeSWITCH的源代码目录,执行如下命令

cd ~/freeswitch/
make mod_distributor-install

然后,在conf/autoload_configs/distributor.conf.xml中进行如下设置:

<list name="dist1" total-weight="10">
<node name="30" weight="1"/>
<node name="31" weight="1"/>
<node name="32" weight="1"/>
<node name="33" weight="1"/>
<node name="34" weight="1"/>
<node name="35" weight="1"/>
<node name="36" weight="1"/>
<node name="37" weight="1"/>
<node name="38" weight="1"/>
<node name="39" weight="1"/>
</list>

其中,我们配置了一个列表(list),它的名字是“dist1”,总体的权重(total-weight)是“10”。该列表有好多节点(node)组成,其中每个节点的权重(weight)为“1” 。可以看出,这些节点的名字跟我们gateway中name属性的最后两位相同。

在源码目录编辑 modules.conf且接触注释

applications/mod_distributor

然后

make mod_distributor && make mod_distributor-install
cd /usr/local/freeswitch/conf/autoload_configs/
vim modules.conf.xml 
解除注释:<load module="mod_distributor"/>
freeswitch>reloadxml
freeswitch>reload mod_distributor

FreeSWITCH加载该模块后,我们就可以先用如下的命令进行一下测试

freeswitch> distributor dist1
32
freeswitch> distributor dist1
35

然后,我们就可以在Dialplan中使用它来帮助我们选线了:

<extension name="gw">
<condition field="destination_number" expression="^(01[358].*)$">
<action application="bridge"data="sofia/gateway/gw${distributor(dist1)}/$1" loop="2"/>
</condition>
</extension>

虽然我们配置了10个网关,但并不一定所
有时间所有的网关都能正常注册上。通过如下方法,就可以让distributor在生成选择节点时,排除掉处于down状态(即不可用状态)的网关:

<action application="bridge"
data="sofia/gateway/gw${distributor(dist1 ${sofia(profile internal gwlist down)})}/$1"/>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值