freeswitch的gateway配置方案优化

 

概述

freeswitch是一款简单好用的VOIP开源软交换平台。

在之前的文章中,我们简单介绍过gateway的三种配置方案,但是实际应用之后发现,方案中的参数设置有缺陷,会导致一些问题。

本文档中,针对具体的gateway配置问题进行分析和解决。

环境

centos:CentOS  release 7.0 (Final)或以上版本

freeswitch:v1.10.7

GCC:4.8.5

之前的gateway配置和问题

配置conf/sip_profile/external/gw-138-5080.xml,设置网关参数,例子中只列举了必须的参数,非注册模式。

<include>

    <gateway name="gw-138-5080">

        <param name="username" value="not-used"/>

        <param name="realm" value="10.55.55.138:5080"/>

        <param name="password" value="not-used"/>

        <param name="register" value="false"/>

        <!--send an options ping every x seconds, failure will unregister and/or mark it down-->

        <param name="ping" value="20"/>

        <param name="ping-min" value="3"/>

        <param name="ping-max" value="6"/>

        <param name="ping-user-agent" value="proxy"/>

    </gateway>

</include>

在使用该网关发起呼叫的时候,会有三个问题。

问题一,gateway的invite消息的from头域“caller_id_number”字段内容错误。

From: "123456" <sip:not-used@10.55.55.138:5080;transport=udp;user=phone>;tag=Kpe5rrr9Nr9jK

问题二,网关参数"ping-user-agent"会导致fs刷新配置(reloadxml)的时候coredump。从core文件分析可以看到“sofia_reg_check_gateway”函数中的问题点。

(gdb) bt

#0  0x00007f430f3ac8c1 in __strlen_sse2_pminub () from /lib64/libc.so.6

#1  0x00007f4310d96974 in t_str_xtra () from /lib64/libsofia-sip-ua.so.0

#2  0x00007f4310d9764d in tl_xtra () from /lib64/libsofia-sip-ua.so.0

#3  0x00007f4310d3d990 in nua_signal () from /lib64/libsofia-sip-ua.so.0

#4  0x00007f4310d38830 in nua_options () from /lib64/libsofia-sip-ua.so.0

#5  0x00007f4308826bf9 in sofia_reg_check_gateway (profile=profile@entry=0xe027f0, now=1684490085) at sofia_reg.c:392

#6  0x00007f43087dac18 in sofia_profile_worker_thread_run (thread=<optimized out>, obj=0xe027f0) at sofia.c:3001

#7  0x00007f4312db2d50 in dummy_worker (opaque=0xe07080) at threadproc/unix/thread.c:151

#8  0x00007f430fce7ea5 in start_thread () from /lib64/libpthread.so.0

#9  0x00007f430f33bb0d in clone () from /lib64/libc.so.6

(gdb) f 5

#5  0x00007f4308826bf9 in sofia_reg_check_gateway (profile=profile@entry=0xe027f0, now=1684490085) at sofia_reg.c:392

392                      nua_options(nh,

(gdb) l

387                      switch_copy_string(pvt->gateway_name, gateway_ptr->name, sizeof(pvt->gateway_name));

388                      nua_handle_bind(nh, pvt);

389

390                      gateway_ptr->pinging = 1;

391                      gateway_ptr->ping_sent = switch_time_now();

392                      nua_options(nh,

393                                           TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)),

394                                           TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),

395                                           SIPTAG_TO_STR(gateway_ptr->options_to_uri), SIPTAG_FROM_STR(gateway_ptr->options_from_uri),

396                                           TAG_IF(gateway_ptr->contact_in_ping, SIPTAG_CONTACT_STR(gateway_ptr->register_contact)),

(gdb)

397                                           TAG_IF(gateway_ptr->options_user_agent, SIPTAG_USER_AGENT_STR(gateway_ptr->options_user_agent)),

398                                           TAG_END());

399

400                      switch_safe_free(user_via);

401                      user_via = NULL;

402               }

(gdb) p gateway_ptr->options_user_agent

$1 = 0x7f430adc3092 <Address 0x7f430adc3092 out of bounds>

问题三,options检测不够灵敏,自动切换时间较长,通过修改“ping-min”和“ping-max”参数的值,达到故障转移40秒内自动切换,故障恢复后40秒内切回。

新的gateway配置方法

vi gw-138-5080.xml

<include>

    <gateway name="gw-138-5080">

    <param name="realm" value="10.55.55.138:5080"/>

    <param name="caller-id-in-from" value="true"/>

    <param name="register" value="false"/>

    <!--send an options ping every x seconds, failure will unregister and/or mark it down-->

    <param name="ping" value="20"/>

    <param name="ping-min" value="2"/>

    <param name="ping-max" value="3"/>

    </gateway>

</include>

新的参数在测试后验证成功,结果符合预期。

总结

freeswitch的gateway概念有多种类型和参数,需要在实际应用场景下测试验证。

gateway的参数详情请参考fs官网文档。

空空如常

求真得真

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值