运行环境:
    CentOS 7.6
    FreeSWICH 1.6.18
 
一、问题场景:
    FreeSWITCH收到REFER命令后,重新发起的INVITE消息中的 "User-to-User" 消息头信息不对,跟REFER命令的 "Refer-To" 消息头中的User-to-User参数值不同。
    具体报文情况如下(省略了部分SIP信息):
REFER sip:mod_sofia@10.2.32.90:5080 SIP/2.0
Via: SIP/2.0/UDP 10.2.32.116:5080;rport;branch=z9hG4bKryvUZZerH16DN
From: <sip:449998@10.2.32.116:5080>;tag=XH27mSc4ZyjaF
To: "Extension 296898" <sip:296898@10.2.32.90>;tag=6g430SNK5Be3m
Call-ID: 46eda73c-76b2-1239-e1b5-487b6b8ad630
Contact: <sip:449998@10.2.32.116:5080;transport=udp>
Refer-To:
<sip:296896@test.refer.com?User-to-User=00C82b264F7267416E693D3131313337303035303030303139393433333634264F7267446E69733D333030393637%3Bencoding%3Dhex>
Referred-By: <sip:10.2.32.116:5080>
User-to-User:
00C8426613D31%3Bencoding%3Dhex INVITE sip:296896@10.32.26.19:50078;rinstance=b4e528536c8c5a3d SIP/2.0
Via: SIP/2.0/UDP 10.2.32.90;rport;branch=z9hG4bKtK4yS4SH849vD
Route: <sip:296896@10.32.26.19:50078>;rinstance=b4e528536c8c5a3d
From: "Extension 296898" <sip:296898@10.2.32.90>;tag=ymDeQZt2ZcK1B
To: <sip:296896@10.32.26.19:50078;rinstance=b4e528536c8c5a3d>
Call-ID: 4992bbb6-76b2-1239-e1b5-487b6b8ad630
Contact: <sip:mod_sofia@10.2.32.90:5060>
Referred-By: <sip:10.2.32.116:5080>
User-to-User:
00C8426613D31%3Bencoding%3Dhex
Remote-Party-ID: "Extension 296898" <sip:296898@10.2.32.90>;party=calling;screen=yes;privacy=off
二、问题原因:
    FreeSWICH默认情况下,处理REFER命令进行盲转时,新发起的INVITE消息中的 "User-to-User" 是从REFER的 "User-to-User" 头中获取的,而非"Refer-to"里的参数
 
    FS处理Refer命令的逻辑:
  • 信令交互逻辑
             
  • 信令处理逻辑
    • REFER的SIP消息头"Refer-To"中的信息,只提取盲转的被叫号码,忽略其他参数(如User-to-User),然后发起新的INVITE
    • 新的INVITE消息中的“User-to-User”头,是根据REFER命令中的“User-to-User”头获取,非“Refer-To”里的参数值
三、解决方案
    FreeSWITCH 收到 REFER 后,取出sip_refer_to头中的值,执行export nolocal 命令,将值设置到未来bridge的B-leg通道上即可。
    增加下面拨号方案即可:
  <extension name="refer request" continue="true">
<condition field="${sip_refer_to}" expression=".+User-to-User=(.+)%3B">
<action application="log" data="INFO yuxiu:change User-to-User by sip_refer_to : sip_refer-to [$1]"/>
<action application="export" data="nolocal:sip_h_User-to-User=$1;encoding=hex"/>
</condition>
</extension>
    通过上面方式,如果FS收到的REFER命令的“Refer-To”头中有User-to-User参数,就取该参数作为后续INVITE的“User-to-User”头,否则依旧取REFER命令中的“User-to-User”头
    修改后,盲转报文将变成下面形式:
REFER sip:mod_sofia@10.2.32.90:5080 SIP/2.0
From: <sip:449998@10.2.32.116:5080>;tag=XH27mSc4ZyjaF
To: "Extension 296898" <sip:296898@10.2.32.90>;tag=6g430SNK5Be3m
Refer-To: <sip:296896@test.refer.com?User-to-User=00C82b264F7267416E693D3131313337303035303030303139393433333634264F7267446E69733D333030393637%3Bencoding%3Dhex>
User-to-User: 00C8426613D31%3Bencoding%3Dhex INVITE sip:296896@10.32.26.19:50078;rinstance=b4e528536c8c5a3d SIP/2.0
From: "Extension 296898" <sip:296898@10.2.32.90>;tag=ymDeQZt2ZcK1B
To: <sip:296896@10.32.26.19:50078;rinstance=b4e528536c8c5a3d>
User-to-User:
00C82b264F7267416E693D3131313337303035303030303139393433333634264F7267446E69733D333030393637%3Bencoding%3Dhex
Remote-Party-ID: "Extension 296898" <sip:296898@10.2.32.90>;party=calling;screen=yes;privacy=off

四、模拟的呼叫场景:

4.1、PBX-FS机器:充当分机注册服务器
     在PBX-FS (10.2.32.90:5060)上注册两个分机:296896 和 296898
     然后让296989 呼叫 449998 进行测试
  • 拨号方案详情:default.xml 
  <!-- 处理refer消息头 -->
<extension name="refer request" continue="true">
<condition field="${sip_refer_to}" expression=".+User-to-User=(.+)%3B">
<action application="log" data="WARNING yuxiu:change User-to-User by sip_refer_to : sip_refer-to [$1]"/>
<action application="export" data="nolocal:sip_h_User-to-User=$1;encoding=hex"/>
</condition>
</extension> <!-- 模拟呼叫IVR -->
<extension name="outbound-ivr">
<condition field="destination_number" expression="^(449998)$">
<action application="bridge" data="sofia/external/$1@10.2.32.116:5080"/>
<action application="hangup" data="Esl Server ERROR"/>
</condition>
</extension> <!-- 模拟呼叫PBX分机 -->
<extension name="outbound-pbx">
<condition field="destination_number" expression="^(296\d{3})$">
<action application="bridge" data="user/${1}"/>
<action application="hangup" data="Esl Server ERROR"/>
</condition>
</extension>
 
4.2、IVR-FS机器:充当IVR导航服务器
    收到来电后,自动应答,然后播放一段提示音后,refer 盲转到296896
  <extension name="outbound-test2">
<condition field="destination_number" expression="^449998$">
<action application="log" data="INFO uui=${sip_h_User-to-User}"/>
<action application="answer"/>
<action application="playback" data="/usr/local/freeswitch/sounds/welcom_to_call_yuxiu_ivr.wav"/>
<action application="deflect" data="sip:296896@test.refer.com?User-to-User=00C82b264F7267416E693D3131313337303035303030303139393433333634264F7267446E69733D333030393637%3Bencoding%3Dhex"/>
<action application="log" data="WARNING refer finished"/>
<action application="hangup" data="refer finished"/>
</condition>
</extension>

4.3、FS测试日志

EXECUTE sofia/internal/296898@10.2.32.90 bridge(sofia/external_90/449998@10.2.32.116:5080)

[DEBUG]  sofia.c:8544 Process REFER to [296896@test.refer.com]
[INFO] mod_dialplan_xml.c:637 Processing 296898 <296898>->296896 in context default
EXECUTE sofia/internal/296898@10.2.32.90 bridge(user/296896)
 

FreeSWITCH 处理Refer盲转时,UUI传递不对(没有将SIP 消息头Refer-To中的User-to-User传递给B-Leg)的更多相关文章

  1. 关于java中是引用传递还是值传递的问题!!!经常在笔试中遇到,今天终于弄明白了!

    关于JAVA中参数传递问题有两种,一种是按值传递(如果是基本类型),另一种是按引用传递(如果是對象).首先以两个例子开始:1)public class Test2 { public static vo ...

  2. Mybatis中使用 #{} 和 ${} 向sql传参时的区别

    今天在工作时,使用MyBatis中向sql传递两个参数时,一直显示SQL语法错误,仔细检查,才发现传入的参数被加上了引号,导致传入的参数(要传入的参数是表名)附近出现语法错误. 错误写法: } a } ...

  3. 转:TCP为什么要3次握手和4次挥手时等待2MSL、 TCP如何保证消息顺序以及可靠性到达

    关于tcp三次握手.四次挥手可以看这里:TCP与UDP的差别以及TCP三次握手.四次挥手 1.TCP为甚要3次握手? 在谢希仁著<计算机网络>第四版中讲“三次握手”的目的是“为了防止已失效 ...

  4. struts2 action配置时 method 省略不写 默认执行方法是父类ActionSuppot中的execute()方法

    struts2 action配置时 method 省略不写 默认执行方法是父类ActionSuppot中的execute()方法

  5. 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UITableViewCell注册(填写)重用标识符:identifier.必须要代码方法中的标识符一致.

    CHENYILONG Blog 使用storyboard显示UITableView时,如果不修改系统默认生成的tableView:cellForRowAtIndexPath:方法中的代码,则必须为UI ...

  6. httpUrlConnection连接网络的用法(用到了handle传递消息,在主线程中更新UI)

    由于httpclient在Android5.0以后已经过时,所以官方推荐使用httpUrlConnection来连接网络,现将该连接的基本方法展示,如下 注意:记得加入<uses-permiss ...

  7. urlencode($url):把url转义,当字符串数据以url的形式传递给web服务器时,字符串中是不允许出现空格和特殊字符串的

    1.对url进行编码转义

  8. jquery mobile跳转到指定id时怎样传递参数

    在jquery mobile 中,每一个页面都是一个page,当我们需要从一个页面跳转到另一个页面时,可以在href中指定id,可是该怎么把一个page中的参数传递到另外一个page中,几经琢磨,发现 ...

  9. C++ 数组作为函数参数时,传递数组大小的方法

    废话不多说,先上错误示范: void fun(int arr[arr_num]) { // ... } int main() { // ... int *arr = new int[10]; fun( ...

随机推荐

  1. “程序包com.sun.org.apache.xml.internal.security.utils不存在”的问题

    方法一(eclipse): 网上大神的回答: 自己写的程序是不建议用com.sun这个玩意儿的..这东西属于“Deprecated and restricted API”.. 而且各种com.sun的 ...

  2. JAVA——JVM参数设置规则以及参数含义

    JVM参数设置规则: -XX:+<option> 启用option,例如:-XX:+PrintGCDetails启动打印GC信息的选项,其中+号表示true,开启的意思-XX:-<o ...

  3. magento2 pub/static没有adminhtml,frontend的解决方案

    (1) 运行php bin/magento setup:static-content:deploy (2) 检查pub/static有没有.htaccess文件 (3) php bin/magento ...

  4. gorilla/mux 的学习

    原文链接:gorilla/mux的学习 源代码: package main import ( "encoding/json" "fmt" "githu ...

  5. Robot Framework(2)——简单运行案例

    1.打开RIDE 之前介绍的3种方式都可以 2.创建工程和测试套件 1>点击File-New Project ①Name:工程命名 ②Parent Directory:上级目录,工程会创建在这个 ...

  6. 算法-排序(1)k路平衡归并与败者树

    const int MaxValue=; //根据实际情况选择最大值 void kwaymerge(Element *r,int k){ int i,q; r=new Element[k]; //在败 ...

  7. 牛客网PAT练兵场-D进制的A+B

    题解:大多数做法是利用循环相除,取余.我是将将A+B传入f函数,利用递归实现D进制的输出 题目地址:https://www.nowcoder.com/questionTerminal/a2063993 ...

  8. 区块链入门到实战(22)之以太坊(Ethereum) – 账号(地址)

    作用: 外部账号 – 用户使用的账号,账户余额. 合约账号 – 智能合约使用的账号,每个智能合约都有一个账号,内存和账户余额 以太坊(Ethereum)网络中,有2种账号: 外部账号 – 用户使用的账 ...

  9. 【免费】windows下如何生成tar.gz,一键生成tar.gz

    废话 一.实验背景 tar.gz 是Linux和Unix下面比较常用的格式,一条命令就可以把文件压缩打包成tar.gz格式,然而这种格式在windows并不多见. Linxu服务器上,tar.gz 包 ...

  10. 发生错误 1069 sqlserver

    ---------------------------SQL Server 服务管理器---------------------------发生错误 1069 - (由于登录失败而无法启动服务.),此 ...