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的通话

相关推荐
白露与泡影7 分钟前
SEATA:Server 到 Golang Client 全链路走读
开发语言·后端·golang
小江的记录本25 分钟前
【Spring全家桶】Spring Cloud 2023.0.x:配置中心:Nacos Config、Apollo(附《思维导图》+《面试高频考点清单》)
java·spring boot·后端·python·spring·spring cloud·面试
IT_陈寒27 分钟前
Redis的LRU淘汰策略坑了我一天血汗
前端·人工智能·后端
jeffer_liu10 小时前
Spring AI 生产级实战:裁判员
java·人工智能·后端·spring·大模型
金銀銅鐵11 小时前
用 Tkinter 实现简单的猜数字游戏
后端·python
copyer_xyf11 小时前
Python 模块与包的导入导出
前端·后端·python
夜微凉411 小时前
三、Spring
java·后端·spring
copyer_xyf11 小时前
Python venv 虚拟环境
前端·后端·python
copyer_xyf13 小时前
Python 如何同时做很多事:进程、线程、协程
前端·后端·python
Full Stack Developme13 小时前
Spring AOP 与 AspectJ
java·后端·spring