簡體   English   中英

Asterisk AGI 腳本在呼叫者掛斷時下降

[英]Asterisk AGI script falls when caller hangup

我有簡單的 AGI 腳本,我需要通過撥打 6666 號碼撥打 101 分機並計算通話后的應答時間。 當被調用者掛斷時一切正常,但是當調用者掛斷 agi 腳本時返回 4。
對不起我的英語不好)

agi.php

#!/usr/bin/php -q
<?php  
require('include/phpagi.php');
$agi = new AGI();
$agi->answer();
$agi->exec("Dial", "SIP/101");
$result = $agi->get_variable("ANSWEREDTIME");
file_put_contents("/tmp/test.txt", json_encode($result));
$agi->hangup();
?>

**sip.conf**
 [general] externaddr=51.15.53.237:5060 localnet=10.18.222.53/255.255.255.0; локальная сеть language=ru context=default allowoverlap=no udpbindaddr=0.0.0.0 tcpenable=no tcpbindaddr=0.0.0.0 transport=udp srvlookup=yes allowguest=no limitonpeers=yes [authentication] [managers-phones](!) type=friend context=call-out secret=qwerty host=dynamic nat=yes qualify=yes canreinvite=no callgroup=1 pickupgroup=1 call-limit=5 dtmfmode=auto disallow=all allow=alaw allow=ulaw allow=g729 allow=g723 allow=g722 [100](managers-phones) callerid="Number 100" <100> [101](managers-phones) callerid="Number 101" <101>

**extensions.conf**
 [general] static=yes writeprotect=no [globals] [default] [handup-sip] exten => _X,,1,HangUp() [call-out] exten => 6666,1.AGI(agi,php) exten => _XXX,1,Dial(SIP/${EXTEN}) include => handup-sip

被叫方掛機時的控制台 output:
 == Using SIP RTP CoS mark 5 > 0x7fabe000deb0 -- Strict RTP learning after remote address set to: 176.213.58.47:7078 -- Executing [6666@call-out:1] AGI("SIP/100-00000016", "agi.php") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/agi.php <SIP/100-00000016>AGI Tx >> agi_request: agi.php <SIP/100-00000016>AGI Tx >> agi_channel: SIP/100-00000016 <SIP/100-00000016>AGI Tx >> agi_language: ru <SIP/100-00000016>AGI Tx >> agi_type: SIP <SIP/100-00000016>AGI Tx >> agi_uniqueid: 1594145722.33 <SIP/100-00000016>AGI Tx >> agi_version: 16.11.1 <SIP/100-00000016>AGI Tx >> agi_callerid: 100 <SIP/100-00000016>AGI Tx >> agi_calleridname: Number 100 <SIP/100-00000016>AGI Tx >> agi_callingpres: 0 <SIP/100-00000016>AGI Tx >> agi_callingani2: 0 <SIP/100-00000016>AGI Tx >> agi_callington: 0 <SIP/100-00000016>AGI Tx >> agi_callingtns: 0 <SIP/100-00000016>AGI Tx >> agi_dnid: 6666 <SIP/100-00000016>AGI Tx >> agi_rdnis: unknown <SIP/100-00000016>AGI Tx >> agi_context: call-out <SIP/100-00000016>AGI Tx >> agi_extension: 6666 <SIP/100-00000016>AGI Tx >> agi_priority: 1 <SIP/100-00000016>AGI Tx >> agi_enhanced: 0.0 <SIP/100-00000016>AGI Tx >> agi_accountcode: <SIP/100-00000016>AGI Tx >> agi_threadid: 140374906681088 <SIP/100-00000016>AGI Tx >> <SIP/100-00000016>AGI Rx << ANSWER > 0x7fabe000deb0 -- Strict RTP switching to RTP target address 176.213.58.47:7078 as source <SIP/100-00000016>AGI Tx >> 200 result=0 <SIP/100-00000016>AGI Rx << EXEC Dial SIP/101 -- AGI Script Executing Application: (Dial) Options: (SIP/101) == Using SIP RTP CoS mark 5 -- Called SIP/101 -- SIP/101-00000017 is ringing > 0x7fabd000cb70 -- Strict RTP learning after remote address set to: 176.213.58.47:8000 -- SIP/101-00000017 answered SIP/100-00000016 -- Channel SIP/101-00000017 joined 'simple_bridge' basic-bridge <dafb98ba-3e18-4c2e-a51c-46f2f7cc7f5b> -- Channel SIP/100-00000016 joined 'simple_bridge' basic-bridge <dafb98ba-3e18-4c2e-a51c-46f2f7cc7f5b> > Bridge dafb98ba-3e18-4c2e-a51c-46f2f7cc7f5b: switching from simple_bridge technology to native_rtp > Locally RTP bridged 'SIP/100-00000016' and 'SIP/101-00000017' in stack > 0x7fabd000cb70 -- Strict RTP switching to RTP target address 176.213.58.47:8000 as source > 0x7fabe000deb0 -- Strict RTP learning complete - Locking on source address 176.213.58.47:7078 -- Channel SIP/101-00000017 left 'native_rtp' basic-bridge <dafb98ba-3e18-4c2e-a51c-46f2f7cc7f5b> -- Channel SIP/100-00000016 left 'native_rtp' basic-bridge <dafb98ba-3e18-4c2e-a51c-46f2f7cc7f5b> <SIP/100-00000016>AGI Tx >> 200 result=-1 <SIP/100-00000016>AGI Rx << GET VARIABLE ANSWEREDTIME <SIP/100-00000016>AGI Tx >> 200 result=1 (6) <SIP/100-00000016>AGI Rx << HANGUP <SIP/100-00000016>AGI Tx >> 200 result=1 -- <SIP/100-00000016>AGI Script agi.php completed, returning 4 == Spawn extension (call-out, 6666, 1) exited non-zero on 'SIP/100-00000016'

主叫掛斷時的控制台 output:
 == Using SIP RTP CoS mark 5 > 0x7fabe000deb0 -- Strict RTP learning after remote address set to: 176.213.58.47:7078 -- Executing [6666@call-out:1] AGI("SIP/100-0000001e", "agi.php") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/agi.php <SIP/100-0000001e>AGI Tx >> agi_request: agi.php <SIP/100-0000001e>AGI Tx >> agi_channel: SIP/100-0000001e <SIP/100-0000001e>AGI Tx >> agi_language: ru <SIP/100-0000001e>AGI Tx >> agi_type: SIP <SIP/100-0000001e>AGI Tx >> agi_uniqueid: 1594145890.45 <SIP/100-0000001e>AGI Tx >> agi_version: 16.11.1 <SIP/100-0000001e>AGI Tx >> agi_callerid: 100 <SIP/100-0000001e>AGI Tx >> agi_calleridname: Number 100 <SIP/100-0000001e>AGI Tx >> agi_callingpres: 0 <SIP/100-0000001e>AGI Tx >> agi_callingani2: 0 <SIP/100-0000001e>AGI Tx >> agi_callington: 0 <SIP/100-0000001e>AGI Tx >> agi_callingtns: 0 <SIP/100-0000001e>AGI Tx >> agi_dnid: 6666 <SIP/100-0000001e>AGI Tx >> agi_rdnis: unknown <SIP/100-0000001e>AGI Tx >> agi_context: call-out <SIP/100-0000001e>AGI Tx >> agi_extension: 6666 <SIP/100-0000001e>AGI Tx >> agi_priority: 1 <SIP/100-0000001e>AGI Tx >> agi_enhanced: 0.0 <SIP/100-0000001e>AGI Tx >> agi_accountcode: <SIP/100-0000001e>AGI Tx >> agi_threadid: 140374906681088 <SIP/100-0000001e>AGI Tx >> <SIP/100-0000001e>AGI Rx << ANSWER > 0x7fabe000deb0 -- Strict RTP switching to RTP target address 176.213.58.47:7078 as source <SIP/100-0000001e>AGI Tx >> 200 result=0 <SIP/100-0000001e>AGI Rx << EXEC Dial SIP/101 -- AGI Script Executing Application: (Dial) Options: (SIP/101) == Using SIP RTP CoS mark 5 -- Called SIP/101 -- SIP/101-0000001f is ringing > 0x7fac0000c120 -- Strict RTP learning after remote address set to: 176.213.58.47:8000 -- SIP/101-0000001f answered SIP/100-0000001e -- Channel SIP/101-0000001f joined 'simple_bridge' basic-bridge <e8f305f8-5d84-4ae7-8be5-babcdefdb5ef> -- Channel SIP/100-0000001e joined 'simple_bridge' basic-bridge <e8f305f8-5d84-4ae7-8be5-babcdefdb5ef> > Bridge e8f305f8-5d84-4ae7-8be5-babcdefdb5ef: switching from simple_bridge technology to native_rtp > Locally RTP bridged 'SIP/100-0000001e' and 'SIP/101-0000001f' in stack > 0x7fac0000c120 -- Strict RTP switching to RTP target address 176.213.58.47:8000 as source -- Channel SIP/101-0000001f left 'native_rtp' basic-bridge <e8f305f8-5d84-4ae7-8be5-babcdefdb5ef> -- Channel SIP/100-0000001e left 'native_rtp' basic-bridge <e8f305f8-5d84-4ae7-8be5-babcdefdb5ef> <SIP/100-0000001e>AGI Tx >> 200 result=-1 <SIP/100-0000001e>AGI Rx << GET VARIABLE ANSWEREDTIME <SIP/100-0000001e>AGI Tx >> 200 result=1 (4) <SIP/100-0000001e>AGI Rx << HANGUP <SIP/100-0000001e>AGI Tx >> 200 result=1 -- <SIP/100-0000001e>AGI Script agi.php completed, returning 4 == Spawn extension (call-out, 6666, 1) exited non-zero on 'SIP/100-0000001e'

結果調用者掛斷時沒有文件/tmp/test.txt,但被調用者掛斷時有。 問題出在哪里? 從源代碼 PHP 7.2.24-0ubuntu0.18.04.6 構建的 Asterisk 16 LTS

我不知道你到底需要做什么,但如果你想在通話發生后得到一些數據,我認為正確的方法是運行掛斷腳本。 查看掛斷腳本的工作原理 - h 擴展和掛斷處理程序:

https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers

在您的情況下,您仍在嘗試在死通道上做一些不正確的方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM