FreeSWITCH与FreeSWITCH对接

背景

使用两台服务器,每台服务器上运行一个FreeSWITCH,我们要实现两台FreeSWITCH上的主机互拨

服务器A信息

服务器IP为192.168.0.38

sh 复制代码
freeswitch@debianh61> sofia status

                     Name	   Type	                                      Data	State
=================================================================================================
            external-ipv6	profile	  sip:mod_sofia@[2408:8214:2a1d:2db1:922b:34ff:feeb:9991]:5080	RUNNING (0)
             192.168.0.38	  alias	                                  internal	ALIASED
                 external	profile	           sip:mod_sofia@192.168.0.38:5080	RUNNING (0)
    external::example.com	gateway	                   sip:joeuser@example.com	NOREG
            internal-ipv6	profile	  sip:mod_sofia@[2408:8214:2a1d:2db1:922b:34ff:feeb:9991]:5060	RUNNING (0)
                 internal	profile	           sip:mod_sofia@192.168.0.38:5060	RUNNING (0)
=================================================================================================
4 profiles 1 alias

服务器B信息

服务器IP为192.168.0.53

sh 复制代码
freeswitch@debianb85> sofia status

                     Name	   Type	                                      Data	State
=================================================================================================
            external-ipv6	profile	  sip:mod_sofia@[2408:8214:2a1d:2db1:76d4:35ff:fed9:207d]:5080	RUNNING (0)
             192.168.0.53	  alias	                                  internal	ALIASED
                 external	profile	           sip:mod_sofia@192.168.0.53:5080	RUNNING (0)
    external::example.com	gateway	                   sip:joeuser@example.com	NOREG
            internal-ipv6	profile	  sip:mod_sofia@[2408:8214:2a1d:2db1:76d4:35ff:fed9:207d]:5060	RUNNING (0)
                 internal	profile	           sip:mod_sofia@192.168.0.53:5060	RUNNING (0)
=================================================================================================
4 profiles 1 alias

具体操作

服务器A

在服务器A上想要拨通B,B相对于A来说就是外地用户,因此我们需要在号码前加拨0加以区别。

修改Dialplan, 添加一个可以匹配分机以0开头的匹配项。我们修改conf/dialplan/default.xml,添加内容如下

xml 复制代码
<extension name="B">
  <condition field="destination_number" expression="^0(.*)$">
     <action application="bridge" data="sofia/external/sip:$1@192.168.0.53:5080"/>
  </condition>
</extension>

在服务器A修改完上述配置后,FreeSWITCH需要重新扫描一下配置,让配置生效.执行以下命令sofia profile internal rescan

sh 复制代码
freeswitch@debianh61> sofia profile internal rescan 
Reload XML [Success]
+OK scan complete

该xml匹配0开头的号码,当匹配后会从本机的external profile出去向B的5080端口发起呼叫。B在收到呼叫请求后会走public profile,根据被叫号码匹配进行transfer。

测试

注册分机

在服务器A上我们注册一个分机1001

在服务器B上我们注册一个分机1000

呼叫

1001上呼叫01000,这里对外呼叫我们加拨了一个0

可以看到呼叫能正常接听

同理要在B上呼通A上的分机的话也做类似的配置就可以。

查看

查看服务器A的日志,我们可以看到有通话往外送

查看服务器B的日志,我们看到收到来自A的通话

相关推荐
smileNicky36 分钟前
SpringBoot系列之集成Pulsar教程
java·spring boot·后端
小翰子_1 小时前
Spring Boot整合Sharding-JDBC实现日志表按月按周分表实战
java·spring boot·后端
踏浪无痕2 小时前
SQLInsight:从JDBC底层到API调用的零侵入SQL监控方案
数据库·后端·开源
superman超哥3 小时前
Rust HashSet与BTreeSet的实现细节:集合类型的底层逻辑
开发语言·后端·rust·编程语言·rust hashset·rust btreeset·集合类型
superman超哥4 小时前
Rust String与&str的内部实现差异:所有权与借用的典型案例
开发语言·后端·rust·rust string·string与str·内部实现·所有权与借用
愈努力俞幸运4 小时前
rust安装
开发语言·后端·rust
踏浪无痕4 小时前
JobFlow 负载感知调度:把任务分给最闲的机器
后端·架构·开源
UrbanJazzerati4 小时前
Python自动化统计工具实战:Python批量分析Salesforce DML操作与错误处理
后端·面试
我爱娃哈哈4 小时前
SpringBoot + Seata + Nacos:分布式事务落地实战,订单-库存一致性全解析
spring boot·分布式·后端
nil5 小时前
记录protoc生成代码将optional改成omitepty问题
后端·go·protobuf