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

相关推荐
Chen_LSN16 分钟前
C语言——深度理解指针(4)
后端
用户6389822458918 分钟前
自定义注解@SyncNeo4j实现增删改导入时自动同步数据节点和关系到Neo4j
后端
AlunYegeer22 分钟前
Spring Boot 多模块服务间 API Token 鉴权排查记录
java·spring boot·后端
沙湖遇雨23 分钟前
3.客户端向服务端建立连接
后端
沙湖遇雨23 分钟前
1.netty源码阅读-管理端Server启动
后端
玖石书25 分钟前
ASP.NET Core迁移Spring系列:运行时与 GC 篇
后端·spring·asp.net
谁来拯救笨小孩27 分钟前
Cursor 流式协议:为何不是 REST,HTTP/2 与双向流怎么选
后端
明月光81827 分钟前
在数据库里做权限控制?重新理解 PostgreSQL 的 RLS(行级安全)
后端
用户2986985301428 分钟前
PDF 转图片?三种方案,覆盖全平台与自动化场景
人工智能·后端
沙湖遇雨29 分钟前
2.启动客户端client
后端