如何为boot2docker中的docker容器配置freeSWITCH?

时间:2015-01-31 23:49:27

标签: docker freeswitch boot2docker

我正在尝试设置运行freeSWITCH的Docker容器,以便我可以在Debian服务器上部署它。

为了开发,我使用在boot2docker中运行freeSWITCH容器的Mac。

我需要容器才能在这两种环境中工作。

我设法通过软电话连接到FS服务器并拨打电话但是在32秒后,呼叫会中断。

freeswitch@internal> version
FreeSWITCH Version 1.4.15-1~64bit (-1 64bit)

这是FS发送的SIP 200 OK数据包,并期望得到答案:

14  0.029449000 192.168.59.103  192.168.59.3    SIP/SDP 1312    Status: 200 OK | 

SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.141:49822;rport=49822;branch=z9hG4bKPjFf3iaNQ0tDY1fySiz1zGSEXSVFpZeE2b;received=192.168.59.3
From: "1000" <sip:1000@192.168.59.103>;tag=tNpJHmkYg0ke5GYyvIhkdBSIMM.ujzXE
To: <sip:5000@192.168.59.103>;tag=6N3793jeayeUe
Call-ID: 4wWTcxr9Q4OqlgT2Fs-8SeOkLhVYXTLb
CSeq: 10007 INVITE
Contact: <sip:5000@172.17.0.6:5060;transport=udp>
User-Agent: FreeSWITCH-mod_sofia/1.4.15-1~64bit
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 333
Remote-Party-ID: "5000" <sip:5000@192.168.59.103>;party=calling;privacy=off;screen=no

v=0
o=FreeSWITCH 1422731206 1422731207 IN IP4 172.17.0.6
s=FreeSWITCH
c=IN IP4 172.17.0.6
t=0 0
m=audio 16386 RTP/SAVP 9 101
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=rtcp:16387 IN IP4 172.17.0.6
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:/NTeSA7Od0+1Uo1/3wIclZwEiKJ+R4Mh8gyTx+5O

然后发生这种情况:

1745    32.031059000    192.168.59.103  192.168.59.3    SIP 664 Request: BYE sip:29716085@192.168.59.3:49822 | 

BYE sip:29716085@192.168.59.3:49822 SIP/2.0
Via: SIP/2.0/UDP 172.17.0.6;rport;branch=z9hG4bK0m429X0ac150r
Max-Forwards: 70
From: <sip:5000@192.168.59.103>;tag=6N3793jeayeUe
To: "1000" <sip:1000@192.168.59.103>;tag=tNpJHmkYg0ke5GYyvIhkdBSIMM.ujzXE
Call-ID: 4wWTcxr9Q4OqlgT2Fs-8SeOkLhVYXTLb
CSeq: 71037748 BYE
Contact: <sip:5000@172.17.0.6:5060;transport=udp>
User-Agent: FreeSWITCH-mod_sofia/1.4.15-1~64bit
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Reason: SIP;cause=408;text="ACK Timeout"
Content-Length: 0

我猜FS从未收到软电话的答案,因为各种NAT层并且掉线,假设它没有连接。

192.168.1.141是我在局域网上的Mac的IP地址(如200 OK数据包的VIA所示)

192.168.59.103是boot2docker VM

192.168.59.3是我在boot2docker虚拟网络上的Mac

172.17.0.xxx是Docker网络上FS服务器的IP地址(此IP会发生变化,具体取决于以前运行的容器数量)

这就是我在sip_profiles / internal.xml上的内容

<param name="rtp-ip" value="$${local_ip_v4}"/>
<!-- ip address to bind to, DO NOT USE HOSTNAMES ONLY IP ADDRESSES -->
<param name="sip-ip" value="$${local_ip_v4}"/>
<param name="hold-music" value="$${hold_music}"/>
<param name="apply-nat-acl" value="nat.auto"/>

<!-- Docker NAT magic -->
<param name="ext-sip-ip" value="$${external_sip_ip}"/>
<param name="ext-rtp-ip" value="$${external_rtp_ip}"/>

在我的vars.xml中

  <X-PRE-PROCESS cmd="set" data="external_rtp_ip=192.168.59.103"/>
  <X-PRE-PROCESS cmd="set" data="external_sip_ip=192.168.59.103"/>

来自fs_cli:

freeswitch@internal> eval ${external_rtp_ip}
192.168.59.103
freeswitch@internal> eval ${external_sip_ip}
192.168.59.103
freeswitch@internal> eval ${ext-rtp-ip}
-ERR no reply

freeswitch@internal> eval ${ext-sip-ip}
-ERR no reply

我为RTP流量设置了端口16384到16484 UDP,5060,5070,5080 UDP&amp;用于SIP的TCP,包括FS和容器中的。

回声测试显示音频双向流动。

知道发生了什么以及如何解决?

2 个答案:

答案 0 :(得分:1)

我的FreeSwitch安装遇到了类似的问题,我通过配置交换机不断ping注册的软电话来解决这个问题,以保持NAT防火墙通道畅通。以下是为我做的设置:

            <param name="nat-options-ping" value="true"/>
            <param name="all-reg-options-ping" value="true"/>

            <!-- One successful options ping is enough to verify that a phone is reachable -->
            <param name="sip-user-ping-min" value="1"/>
            <!-- Three pings need to be lost to consider the phone disconnected -->
            <param name="sip-user-ping-max" value="4"/>

            <param name="unregister-on-options-fail" value="true"/>

            <!-- Freeswitch is coded to send
            pings at variable intervals with the mean value determined by the
            variable below and a normal distribution with a deviation of half the
            interval value. -->
            <param name="ping-mean-interval" value="15"/>

他们转到sip_profiles / internal.xml。

答案 1 :(得分:0)

好的,这是更新。

事实证明问题是因为FS无法正确检测到其IP并且它发回的数据包包含在错误的IP中。

我想出了这个脚本作为我的容器启动序列的一部分: https://github.com/Coaxial/mushimushi/blob/a29ae537314e89bc7f9808c2bd7fdb4917eafa04/lib/freeswitch_conf/start.sh#L7-L21

然后我将生成的XML文件包含在常规配置中:https://github.com/Coaxial/mushimushi/blob/a29ae537314e89bc7f9808c2bd7fdb4917eafa04/lib/freeswitch_conf/freeswitch.xml#L3

这样我可以引用变量来配置相关的Sofia配置文件:https://github.com/Coaxial/mushimushi/blob/a29ae537314e89bc7f9808c2bd7fdb4917eafa04/lib/freeswitch_conf/autoload_configs/sofia.conf.xml#L29-L32

这在boot2docker中运行时有效,但在&#34; vanilla&#34;码头工人。