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:[email protected]:5080	RUNNING (0)
    external::example.com	gateway	                   sip:[email protected]	NOREG
            internal-ipv6	profile	  sip:mod_sofia@[2408:8214:2a1d:2db1:922b:34ff:feeb:9991]:5060	RUNNING (0)
                 internal	profile	           sip:[email protected]: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:[email protected]:5080	RUNNING (0)
    external::example.com	gateway	                   sip:[email protected]	NOREG
            internal-ipv6	profile	  sip:mod_sofia@[2408:8214:2a1d:2db1:76d4:35ff:fed9:207d]:5060	RUNNING (0)
                 internal	profile	           sip:[email protected]: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:[email protected]: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的通话

相关推荐
编程乐学(Arfan开发工程师)9 分钟前
42、响应处理-【源码分析】-浏览器与PostMan内容协商完全适配
java·spring boot·后端·测试工具·lua·postman
汪子熙13 分钟前
深入解析互斥锁(Mutex):并发编程中的关键同步机制
后端·面试
Livingbody13 分钟前
mac系统下永久设置环境变量之【huggingface更换镜像站】
后端
Livingbody14 分钟前
Transformers Pipeline 文本情感分类
后端
坚持学习永不言弃15 分钟前
单例模式
后端
coding随想16 分钟前
数据结构界的‘直男’——线性结构的全方位解析
后端
十字路口的火丁17 分钟前
gin + endless 实现服务平滑重启
后端
Robin45821 分钟前
Go 中的有效设计模式
后端
程序员麻辣烫22 分钟前
Go的优雅退出
后端·go
啊哈灵机一动25 分钟前
SNMP 转发协议设计文档
后端