打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
FreeSwitch网关轮询模块mod

安装

编辑 modules.conf且添加以下行:

applications/mod_distributor

然后

make mod_distributor && make mod_distributor-install

配置FreeSwitch自动加载该模块

$FS_CONF/autoload_configs/modules.conf.xml 中添加一行

<load module="mod_distributor"/>

使用方法

有好几种方法可以使用这个模块,不过它通常被用于bridge这个application,如,你有两个网关定义去分发,那么dailstring可以如此:

<action application="bridge" data="sofia/gateway/${distributor(distributor_list)}/${destination_number}"/>

-- or--

<action application="bridge" data="sofia/external/${destination_number}@${distributor(distributor_list)}"/>

在fs_cli中重新加载distributor.conf.xml:

reloadxmldistributor_ctl reload

配置

mod_distributor 通过配置文件中返回的节点值来工作,如:

<configuration name="distributor.conf" description="Distributor Configuration">  <lists>    <!-- every 10 calls to test you will get foo1 once and foo2 9 times...yes NINE TIMES! -->    <!-- this is not the same as 100 with 10 and 90 that would do foo1 10 times in a row then foo2 90 times in a row -->    <list name="test" total-weight="10">      <node name="foo1" weight="1"/>      <node name="foo2" weight="9"/>    </list>  </lists></configuration>

在名称为"test"的列表中,总权重是10,而且所有节点的权重值合为10, 当一个分发呼叫到test时,它会第一时间返回foo1,在后九次会返回foo2.再然后下一次返回foo1,9次foo2,一直循环下去。

如果是一个交替列表的可以如下方式:

<list name="alternating" total-weight="2">    <node name="alt_one" weight="1"/>    <node name="alt_two" weight="1"/>  </list>

在上述的例子中,每个呼叫到分发(alternating)将在alt_one and alt_two 中交替。

你可以使用这个方式发送到多个网关实现简单的负载均衡。我们可以看看三个不同的网关定义成gateway1,gateway2,gateway3.把每三个呼叫送给每一个网关,你需要在distributor.conf.xml中配置:

  <list name="3gw" total-weight="3">    <node name="gateway1" weight="1"/>    <node name="gateway2" weight="1"/>    <node name="gateway3" weight="1"/>  </list>

定义路由如下:

<extension name="3-way gateway distro">    <condition field="destination_number" expression="^(.*)$">      <action application="bridge" data="sofia/gateway/${distributor(3gw)}/$1"/>    </condition>  </extension>

这个分发模块支持按网关名称去使用,每个呼叫到达路由时将触发分发模块变换使用不同的gw去响应呼叫。

当你的拨号路由在上一个bridge时失败,你想继续呼叫且在在xml路由中循环:

 <extension name="3-way gateway distributor">    <condition field="destination_number" expression="^(.*)$">      <action application="set" data="continue_on_fail=true"/>      <action application="set" data="hangup_after_bridge=true"/>      <action application="bridge" data="sofia/gateway/${distributor(3gw)}/$1" loop="3"/>    </condition>  </extension>

如果有不可达的网关,应在路由中排除不可达网关

<action application="bridge" data="sofia/gateway/${distributor(<listname> ${sofia(profile <profilename> gwlist down)})}/$1"/>

--or--

注意:括号是可选变量:${foo(bar)} 等同于 ${foo bar}

<action application="bridge" data="sofia/gateway/${distributor <listname> ${sofia profile <profilename> gwlist down}}/$1"/>

--or--

<action application="bridge" data="sofia/gateway/${expand(distributor <listname> \${sofia(profile <profilename> gwlist down)})}/$1"/>

API Command

如何执行以上命令在命令行中呢:

expand distributor <listname> ${sofia profile <profilename> gwlist down}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
什么是网关(Gateway)、网桥(Gate Bridge)
Freeswitch之SIP模块
《FreeSWITCH: VoIP实战》: 运行 FreeSWITCH
you dao 翻译
跟我学SpringCloud | 第十三篇:Spring Cloud Gateway服务化和过滤器
搭建eureka,gateway,admin,redis,docker系列一gateway
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服