【问题标题】:Asterisk cannot hear sound on Wifi network onlyAsterisk 只能在 Wifi 网络上听不到声音
【发布时间】:2014-03-28 09:06:55
【问题描述】:

我在 CentOS 6.5 上安装了 Asterisk + FreePBX。

Case 1
Asterisk + FreePBX + CentOS 6.5
Phone A - Android 4G newtork (Linphone, PCMA codec)
Phone B - Android Wifi network (Linphone, PCMA codec)
If I can make a call to Phone B from Phone A, it works and answers the phone. 
However, I can only hear sound from Phone A when I speak on Phone B.

我认为是 NAT 问题,并检查了所有防火墙的 Asterisk。 Wifi网络也没有问题。有没有办法正确更改 NAT 设置?谢谢。

这是我打电话和打电话时的 Asterisk CLI 日志。

  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
    -- Executing [1004@from-internal:1] Set("SIP/1003-0000005e", "__RINGTIMER=15") in new stack
    -- Executing [1004@from-internal:2] Macro("SIP/1003-0000005e", "exten-vm,novm,1004,0,0,0") in new stack
    -- Executing [s@macro-exten-vm:1] Macro("SIP/1003-0000005e", "user-callerid,") in new stack
    -- Executing [s@macro-user-callerid:1] Set("SIP/1003-0000005e", "TOUCH_MONITOR=1395938841.94") in new stack
    -- Executing [s@macro-user-callerid:2] Set("SIP/1003-0000005e", "AMPUSER=1003") in new stack
    -- Executing [s@macro-user-callerid:3] GotoIf("SIP/1003-0000005e", "0?report") in new stack
    -- Executing [s@macro-user-callerid:4] ExecIf("SIP/1003-0000005e", "1?Set(REALCALLERIDNUM=1003)") in new stack
    -- Executing [s@macro-user-callerid:5] Set("SIP/1003-0000005e", "AMPUSER=1003") in new stack
    -- Executing [s@macro-user-callerid:6] GotoIf("SIP/1003-0000005e", "0?limit") in new stack
    -- Executing [s@macro-user-callerid:7] Set("SIP/1003-0000005e", "AMPUSERCIDNAME=Third") in new stack
    -- Executing [s@macro-user-callerid:8] GotoIf("SIP/1003-0000005e", "0?report") in new stack
    -- Executing [s@macro-user-callerid:9] Set("SIP/1003-0000005e", "AMPUSERCID=1003") in new stack
    -- Executing [s@macro-user-callerid:10] Set("SIP/1003-0000005e", "__DIAL_OPTIONS=Ttr") in new stack
    -- Executing [s@macro-user-callerid:11] Set("SIP/1003-0000005e", "CALLERID(all)="Third" <1003>") in new stack
    -- Executing [s@macro-user-callerid:12] GotoIf("SIP/1003-0000005e", "0?limit") in new stack
    -- Executing [s@macro-user-callerid:13] ExecIf("SIP/1003-0000005e", "0?Set(GROUP(concurrency_limit)=1003)") in new stack
    -- Executing [s@macro-user-callerid:14] GosubIf("SIP/1003-0000005e", "7?sub-ccss,s,1(macro-exten-vm,1004)") in new stack
    -- Executing [s@sub-ccss:1] ExecIf("SIP/1003-0000005e", "0?Return()") in new stack
    -- Executing [s@sub-ccss:2] Set("SIP/1003-0000005e", "CCSS_SETUP=TRUE") in new stack
    -- Executing [s@sub-ccss:3] GosubIf("SIP/1003-0000005e", "0?monitor_config,1(macro-exten-vm,1004):monitor_default,1(macro-exten-vm,1004)") in new stack
    -- Executing [monitor_default@sub-ccss:1] GotoIf("SIP/1003-0000005e", "1?is_exten") in new stack
    -- Goto (sub-ccss,monitor_default,4)
    -- Executing [monitor_default@sub-ccss:4] Set("SIP/1003-0000005e", "CALLCOMPLETION(cc_monitor_policy)=generic") in new stack
    -- Executing [monitor_default@sub-ccss:5] Set("SIP/1003-0000005e", "CALLCOMPLETION(cc_max_monitors)=5") in new stack
    -- Executing [monitor_default@sub-ccss:6] Return("SIP/1003-0000005e", "TRUE") in new stack
    -- Executing [s@sub-ccss:4] GosubIf("SIP/1003-0000005e", "7?agent_config,1():agent_default,1()") in new stack
    -- Executing [agent_config@sub-ccss:1] Set("SIP/1003-0000005e", "CALLCOMPLETION(cc_agent_policy)=generic") in new stack
    -- Executing [agent_config@sub-ccss:2] Set("SIP/1003-0000005e", "CALLCOMPLETION(cc_offer_timer)=30") in new stack
    -- Executing [agent_config@sub-ccss:3] Set("SIP/1003-0000005e", "CALLCOMPLETION(ccbs_available_timer)=") in new stack
    -- Executing [agent_config@sub-ccss:4] Set("SIP/1003-0000005e", "CALLCOMPLETION(ccnr_available_timer)=") in new stack
    -- Executing [agent_config@sub-ccss:5] Set("SIP/1003-0000005e", "CALLCOMPLETION(cc_callback_macro)=ccss-default") in new stack
    -- Executing [agent_config@sub-ccss:6] ExecIf("SIP/1003-0000005e", "1?Set(CALLCOMPLETION(cc_recall_timer)=)") in new stack
    -- Executing [agent_config@sub-ccss:7] ExecIf("SIP/1003-0000005e", "1?Set(CALLCOMPLETION(cc_max_agents)=)") in new stack
    -- Executing [agent_config@sub-ccss:8] ExecIf("SIP/1003-0000005e", "0?Set(CALLCOMPLETION(cc_agent_dialstring)=Local/1003_1004@from-ccss-)") in new stack
    -- Executing [agent_config@sub-ccss:9] Set("SIP/1003-0000005e", "CALLCOMPLETION(cc_callback_macro)=ccss-default") in new stack
    -- Executing [agent_config@sub-ccss:10] Return("SIP/1003-0000005e", "") in new stack
    -- Executing [s@sub-ccss:5] Set("SIP/1003-0000005e", "DB(AMPUSER/1003/ccss/last_number)=1004") in new stack
    -- Executing [s@sub-ccss:6] Return("SIP/1003-0000005e", "") in new stack
    -- Executing [s@macro-user-callerid:15] ExecIf("SIP/1003-0000005e", "0?Set(CHANNEL(language)=)") in new stack
    -- Executing [s@macro-user-callerid:16] GotoIf("SIP/1003-0000005e", "0?continue") in new stack
    -- Executing [s@macro-user-callerid:17] ExecIf("SIP/1003-0000005e", "1?Set(__CALLEE_ACCOUNCODE=)") in new stack
    -- Executing [s@macro-user-callerid:18] Set("SIP/1003-0000005e", "__TTL=64") in new stack
    -- Executing [s@macro-user-callerid:19] GotoIf("SIP/1003-0000005e", "1?continue") in new stack
    -- Goto (macro-user-callerid,s,30)
    -- Executing [s@macro-user-callerid:30] Set("SIP/1003-0000005e", "CALLERID(number)=1003") in new stack
    -- Executing [s@macro-user-callerid:31] Set("SIP/1003-0000005e", "CALLERID(name)=Third") in new stack
    -- Executing [s@macro-user-callerid:32] Set("SIP/1003-0000005e", "CDR(cnum)=1003") in new stack
    -- Executing [s@macro-user-callerid:33] Set("SIP/1003-0000005e", "CDR(cnam)=Third") in new stack
    -- Executing [s@macro-user-callerid:34] Set("SIP/1003-0000005e", "CHANNEL(language)=en") in new stack
    -- Executing [s@macro-exten-vm:2] Set("SIP/1003-0000005e", "RingGroupMethod=none") in new stack
    -- Executing [s@macro-exten-vm:3] Set("SIP/1003-0000005e", "__EXTTOCALL=1004") in new stack
    -- Executing [s@macro-exten-vm:4] Set("SIP/1003-0000005e", "__PICKUPMARK=1004") in new stack
    -- Executing [s@macro-exten-vm:5] Set("SIP/1003-0000005e", "RT=") in new stack
    -- Executing [s@macro-exten-vm:6] ExecIf("SIP/1003-0000005e", "0?Macro(vm,novm,DIRECTDIAL,)") in new stack
    -- Executing [s@macro-exten-vm:7] ExecIf("SIP/1003-0000005e", "0?MacroExit()") in new stack
    -- Executing [s@macro-exten-vm:8] Gosub("SIP/1003-0000005e", "sub-record-check,s,1(exten,1004,)") in new stack
    -- Executing [s@sub-record-check:1] Set("SIP/1003-0000005e", "REC_POLICY_MODE_SAVE=") in new stack
    -- Executing [s@sub-record-check:2] GotoIf("SIP/1003-0000005e", "1?check") in new stack
    -- Goto (sub-record-check,s,7)
    -- Executing [s@sub-record-check:7] Set("SIP/1003-0000005e", "__MON_FMT=wav") in new stack
    -- Executing [s@sub-record-check:8] GotoIf("SIP/1003-0000005e", "1?next") in new stack
    -- Goto (sub-record-check,s,11)
    -- Executing [s@sub-record-check:11] ExecIf("SIP/1003-0000005e", "0?Return()") in new stack
    -- Executing [s@sub-record-check:12] ExecIf("SIP/1003-0000005e", "0?Set(__REC_POLICY_MODE=)") in new stack
    -- Executing [s@sub-record-check:13] GotoIf("SIP/1003-0000005e", "0?exten,1") in new stack
    -- Executing [s@sub-record-check:14] Set("SIP/1003-0000005e", "__REC_STATUS=INITIALIZED") in new stack
    -- Executing [s@sub-record-check:15] Set("SIP/1003-0000005e", "NOW=1395938841") in new stack
    -- Executing [s@sub-record-check:16] Set("SIP/1003-0000005e", "__DAY=28") in new stack
    -- Executing [s@sub-record-check:17] Set("SIP/1003-0000005e", "__MONTH=03") in new stack
    -- Executing [s@sub-record-check:18] Set("SIP/1003-0000005e", "__YEAR=2014") in new stack
    -- Executing [s@sub-record-check:19] Set("SIP/1003-0000005e", "__TIMESTR=20140328-014721") in new stack
    -- Executing [s@sub-record-check:20] Set("SIP/1003-0000005e", "__FROMEXTEN=1003") in new stack
    -- Executing [s@sub-record-check:21] Set("SIP/1003-0000005e", "__CALLFILENAME=exten-1004-1003-20140328-014721-1395938841.94") in new stack
    -- Executing [s@sub-record-check:22] Goto("SIP/1003-0000005e", "exten,1") in new stack
    -- Goto (sub-record-check,exten,1)
    -- Executing [exten@sub-record-check:1] GotoIf("SIP/1003-0000005e", "0?callee") in new stack
    -- Executing [exten@sub-record-check:2] Set("SIP/1003-0000005e", "__REC_POLICY_MODE=dontcare") in new stack
    -- Executing [exten@sub-record-check:3] GotoIf("SIP/1003-0000005e", "1?caller") in new stack
    -- Goto (sub-record-check,exten,10)
    -- Executing [exten@sub-record-check:10] Set("SIP/1003-0000005e", "__REC_POLICY_MODE=dontcare") in new stack
    -- Executing [exten@sub-record-check:11] GosubIf("SIP/1003-0000005e", "0?record,1(exten,1004,1003)") in new stack
    -- Executing [exten@sub-record-check:12] Return("SIP/1003-0000005e", "") in new stack
    -- Executing [s@macro-exten-vm:9] GotoIf("SIP/1003-0000005e", "1?macrodial") in new stack
    -- Goto (macro-exten-vm,s,15)
    -- Executing [s@macro-exten-vm:15] GosubIf("SIP/1003-0000005e", "0?clrheader,1()") in new stack
    -- Executing [s@macro-exten-vm:16] Macro("SIP/1003-0000005e", "dial-one,,Ttr,1004") in new stack
    -- Executing [s@macro-dial-one:1] Set("SIP/1003-0000005e", "DEXTEN=1004") in new stack
    -- Executing [s@macro-dial-one:2] Set("SIP/1003-0000005e", "DIALSTATUS_CW=") in new stack
    -- Executing [s@macro-dial-one:3] GosubIf("SIP/1003-0000005e", "0?screen,1()") in new stack
    -- Executing [s@macro-dial-one:4] GosubIf("SIP/1003-0000005e", "0?cf,1()") in new stack
    -- Executing [s@macro-dial-one:5] GotoIf("SIP/1003-0000005e", "1?skip1") in new stack
    -- Goto (macro-dial-one,s,8)
    -- Executing [s@macro-dial-one:8] GotoIf("SIP/1003-0000005e", "0?nodial") in new stack
    -- Executing [s@macro-dial-one:9] GotoIf("SIP/1003-0000005e", "0?continue") in new stack
    -- Executing [s@macro-dial-one:10] Set("SIP/1003-0000005e", "EXTHASCW=ENABLED") in new stack
    -- Executing [s@macro-dial-one:11] GotoIf("SIP/1003-0000005e", "0?next1:cwinusebusy") in new stack
    -- Goto (macro-dial-one,s,23)
    -- Executing [s@macro-dial-one:23] GotoIf("SIP/1003-0000005e", "1?next3:continue") in new stack
    -- Goto (macro-dial-one,s,24)
    -- Executing [s@macro-dial-one:24] ExecIf("SIP/1003-0000005e", "0?Set(DIALSTATUS_CW=BUSY)") in new stack
    -- Executing [s@macro-dial-one:25] GotoIf("SIP/1003-0000005e", "0?nodial") in new stack
    -- Executing [s@macro-dial-one:26] GosubIf("SIP/1003-0000005e", "1?dstring,1():dlocal,1()") in new stack
    -- Executing [dstring@macro-dial-one:1] Set("SIP/1003-0000005e", "DSTRING=") in new stack
    -- Executing [dstring@macro-dial-one:2] Set("SIP/1003-0000005e", "DEVICES=1004") in new stack
    -- Executing [dstring@macro-dial-one:3] ExecIf("SIP/1003-0000005e", "0?Return()") in new stack
    -- Executing [dstring@macro-dial-one:4] ExecIf("SIP/1003-0000005e", "0?Set(DEVICES=004)") in new stack
    -- Executing [dstring@macro-dial-one:5] Set("SIP/1003-0000005e", "LOOPCNT=1") in new stack
    -- Executing [dstring@macro-dial-one:6] Set("SIP/1003-0000005e", "ITER=1") in new stack
    -- Executing [dstring@macro-dial-one:7] Set("SIP/1003-0000005e", "THISDIAL=SIP/1004") in new stack
    -- Executing [dstring@macro-dial-one:8] GosubIf("SIP/1003-0000005e", "1?zap2dahdi,1()") in new stack
    -- Executing [zap2dahdi@macro-dial-one:1] ExecIf("SIP/1003-0000005e", "0?Return()") in new stack
    -- Executing [zap2dahdi@macro-dial-one:2] Set("SIP/1003-0000005e", "NEWDIAL=") in new stack
    -- Executing [zap2dahdi@macro-dial-one:3] Set("SIP/1003-0000005e", "LOOPCNT2=1") in new stack
    -- Executing [zap2dahdi@macro-dial-one:4] Set("SIP/1003-0000005e", "ITER2=1") in new stack
    -- Executing [zap2dahdi@macro-dial-one:5] Set("SIP/1003-0000005e", "THISPART2=SIP/1004") in new stack
    -- Executing [zap2dahdi@macro-dial-one:6] ExecIf("SIP/1003-0000005e", "0?Set(THISPART2=DAHDI/1004)") in new stack
    -- Executing [zap2dahdi@macro-dial-one:7] Set("SIP/1003-0000005e", "NEWDIAL=SIP/1004&") in new stack
    -- Executing [zap2dahdi@macro-dial-one:8] Set("SIP/1003-0000005e", "ITER2=2") in new stack
    -- Executing [zap2dahdi@macro-dial-one:9] GotoIf("SIP/1003-0000005e", "0?begin2") in new stack
    -- Executing [zap2dahdi@macro-dial-one:10] Set("SIP/1003-0000005e", "THISDIAL=SIP/1004") in new stack
    -- Executing [zap2dahdi@macro-dial-one:11] Return("SIP/1003-0000005e", "") in new stack
    -- Executing [dstring@macro-dial-one:9] Set("SIP/1003-0000005e", "DSTRING=SIP/1004&") in new stack
    -- Executing [dstring@macro-dial-one:10] Set("SIP/1003-0000005e", "ITER=2") in new stack
    -- Executing [dstring@macro-dial-one:11] GotoIf("SIP/1003-0000005e", "0?begin") in new stack
    -- Executing [dstring@macro-dial-one:12] Set("SIP/1003-0000005e", "DSTRING=SIP/1004") in new stack
    -- Executing [dstring@macro-dial-one:13] Return("SIP/1003-0000005e", "") in new stack
    -- Executing [s@macro-dial-one:27] GotoIf("SIP/1003-0000005e", "0?nodial") in new stack
    -- Executing [s@macro-dial-one:28] GotoIf("SIP/1003-0000005e", "0?skiptrace") in new stack
    -- Executing [s@macro-dial-one:29] GosubIf("SIP/1003-0000005e", "1?ctset,1():ctclear,1()") in new stack
    -- Executing [ctset@macro-dial-one:1] Set("SIP/1003-0000005e", "DB(CALLTRACE/1004)=1003") in new stack
    -- Executing [ctset@macro-dial-one:2] Return("SIP/1003-0000005e", "") in new stack
    -- Executing [s@macro-dial-one:30] Set("SIP/1003-0000005e", "D_OPTIONS=Ttr") in new stack
    -- Executing [s@macro-dial-one:31] ExecIf("SIP/1003-0000005e", "0?SIPAddHeader(Alert-Info: )") in new stack
    -- Executing [s@macro-dial-one:32] ExecIf("SIP/1003-0000005e", "0?SIPAddHeader()") in new stack
    -- Executing [s@macro-dial-one:33] ExecIf("SIP/1003-0000005e", "0?Set(CHANNEL(musicclass)=)") in new stack
    -- Executing [s@macro-dial-one:34] GosubIf("SIP/1003-0000005e", "0?qwait,1()") in new stack
    -- Executing [s@macro-dial-one:35] Set("SIP/1003-0000005e", "__CWIGNORE=") in new stack
    -- Executing [s@macro-dial-one:36] Set("SIP/1003-0000005e", "__KEEPCID=TRUE") in new stack
    -- Executing [s@macro-dial-one:37] GotoIf("SIP/1003-0000005e", "0?usegoto,1") in new stack
    -- Executing [s@macro-dial-one:38] GotoIf("SIP/1003-0000005e", "0?godial") in new stack
    -- Executing [s@macro-dial-one:39] Gosub("SIP/1003-0000005e", "sub-presencestate-display,s,1(1004)") in new stack
    -- Executing [s@sub-presencestate-display:1] Goto("SIP/1003-0000005e", "state-,1") in new stack
    -- Goto (sub-presencestate-display,state-,1)
    -- Executing [state-@sub-presencestate-display:1] Set("SIP/1003-0000005e", "PRESENCESTATE_DISPLAY=") in new stack
    -- Executing [state-@sub-presencestate-display:2] Return("SIP/1003-0000005e", "") in new stack
    -- Executing [s@macro-dial-one:40] Set("SIP/1003-0000005e", "CONNECTEDLINE(name,i)=fourth") in new stack
    -- Executing [s@macro-dial-one:41] Set("SIP/1003-0000005e", "CONNECTEDLINE(num)=1004") in new stack
    -- Executing [s@macro-dial-one:42] Set("SIP/1003-0000005e", "D_OPTIONS=TtrI") in new stack
    -- Executing [s@macro-dial-one:43] Dial("SIP/1003-0000005e", "SIP/1004,,TtrI") in new stack
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
    -- Called SIP/1004
    -- Connected line update to SIP/1003-0000005e prevented.
    -- SIP/1004-0000005f is ringing
    -- SIP/1004-0000005f is ringing
    -- Connected line update to SIP/1003-0000005e prevented.
    -- SIP/1004-0000005f answered SIP/1003-0000005e

================================================ ===============================

SIP 联系人

WiFi 上的安卓

Addr->IP     : 14.63.12.134:5060
Reg. Contact : sip:1000@14.63.12.134

4G LTE 上的 Android

Addr->IP     : 223.62.202.25:58184
Reg. Contact : sip:1002@223.62.202.25:58184

Wifi 上的 Android 似乎无法获取正确的地址。它不显示发送语音的特定端口。

【问题讨论】:

  • asterisk -rvvvvv的输出是什么并尝试sip debugsip set debug on并配置“nat”和“qualify”(voip-info.org/wiki/view/Asterisk+sip+nat
  • 我发布了 Asterisk 日志。看起来不错。
  • 您是否已经转发 SIP 端口(UDP 5060、10000-20000)到路由器/防火墙上的星号机器?您需要在 rtp 调试中检查 ip,您应该看到类似:Got RTP packet from &lt;IP&gt;Sent RTP packet to &lt;IP&gt;。在 sip.conf 的“常规”上下文设置中激活 NAT:nat=yesexternip=&lt;YOUR REAL IP&gt;localnet=&lt;LOCANET/MASK&gt;
  • @pce 是的。我已经打开了这些端口,更改了您提到的设置。它正在LTE网络上工作。但是,它不仅在家里的 Wifi 网络上工作……很奇怪……

标签: asterisk


【解决方案1】:

这就是我喜欢简单干净的 Asterisk 的原因,你的控制台不会因为一个呼叫而像这样被淹没。 :)

如果您绝对确定编解码器没有问题,则音频 RTP 未到达手机。检查 SIP INVITE 消息的发送位置(假设 1003 是电话不工作):

> sip show peer 1003

查找编解码器信息。如果它们很好,请查看 NAT。设置

> sip set debug on

或者对于特定的同伴:

> sip set debug on peer 1003

然后检查您的标题,特别是 Contact: 标题,其中显示“嘿,请在此处联系我”。

如果创建了呼叫,这意味着控制信号通过(您可以在任一电话中呼叫和挂断),那么我很确定这是一个编解码器问题。如果控件不是 100% 正常(例如,您在一部手机上挂断而另一部不知道),那么可能是网络问题。

希望对你有帮助!

【讨论】:

  • 然后使用 SIP 调试检查他们在哪里发送/期待音频。
  • 好。我检查了它发送语音的联系人数据。它没有特定的端口..现在我需要找出如何去做。也许我需要 stun 服务器才能找到它? @查理布朗
  • 准确地说,将语音发送到哪里取决于每个呼叫 (INVITE),在 SDP 描述中它包括端口。但我同意这两个不同的联系人有点奇怪。也许您应该考虑在您的 WiFI 路由器中设置 SIP ALG。对不起,我已经帮不上忙了!
  • 谢谢查理!我发现这是NAT问题。我打开了 Stun 服务器,它现在可以工作了 :)
  • 太棒了!这些绝非易事;)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多