[asterisk-users] FastAGI script and DIAL execution
Alejandro Recarey
alexrecarey at gmail.com
Mon Jun 25 05:17:27 CDT 2012
Hi all,
I am trying to control the whole call using a FastAGI script. To that
effect I launch a FastAGI script (written with asterisk-java).
Basically, I want to DIAL from within the FastAGI script. When the call
ends I want to control the hangup (if executed at the remote end), and
depending on the cause, dial again, play a message, or hang up. This is a
pretty standard telephony scenario. I did it before by executing the AGI,
setting variables, calling the DIAL command from the dialplan, and then
executing a second AGI script for the cleanup logic. However, now that I am
using FastAGI it seems like a better idea to keep the AGI script alive
during the duration of the call. This gives me a lot of control and
fexibility on reporting.
However, as far as I can tell, once the called party hangs up, the CDR is
generated and posted, _even though my script is still in execution_! As you
can see from the sample below, the called party hangs up, and dialplan
execution starts immediately at the h extension, even though my script is
still running. In fact, I have quite a bit of cleanup to do, adding
variables to the CDR's, and none of them are saved! I believe this is
because the CDR is already finised.
It's like if once you call the DIAL aplication, the dialplan forks off and
your script is running in a different place. I do not understand it. I
assumed when I called DIAL from within a script, that the script execution
would suspend, but be resumed once the DIAL command returned, but this is
not what is happening.
Is there any way to get that behaviour?
Regards,
Alex
"Entering customer extension"
-- Executing [629999999 at customer:2] Verbose("SIP/139255423-0000004c",
"5,"Dialed - 629999999"") in new stack
> "Dialed - 629999999"
-- Executing [629999999 at customer:3] Set("SIP/139255423-0000004c",
"origincontext=customer") in new stack
-- Executing [629999999 at customer:4] Goto("SIP/139255423-0000004c",
"transform,629999999,1") in new stack
-- Goto (transform,629999999,1)
-- Executing [629999999 at transform:1] Goto("SIP/139255423-0000004c",
"customer,0034629999999,transform") in new stack
-- Goto (customer,0034629999999,5)
-- Executing [0034629999999 at customer:5]
Verbose("SIP/139255423-0000004c", "5,"New dialnum - 0034629999999"") in new
stack
> "New dialnum - 0034629999999"
-- Executing [0034629999999 at customer:6] Set("SIP/139255423-0000004c",
"CDR(server)=7") in new stack
-- Executing [0034629999999 at customer:7] Set("SIP/139255423-0000004c",
"CDR(srcip)=") in new stack
-- Executing [0034629999999 at customer:8] AGI("SIP/139255423-0000004c",
"agi://localhost/auth") in new stack
AGI Tx >> agi_network: yes
AGI Tx >> agi_network_script: auth
<SIP/139255423-0000004c>AGI Tx >> agi_request: agi://localhost/auth
<SIP/139255423-0000004c>AGI Tx >> agi_channel: SIP/139255423-0000004c
<SIP/139255423-0000004c>AGI Tx >> agi_language: es
<SIP/139255423-0000004c>AGI Tx >> agi_type: SIP
<SIP/139255423-0000004c>AGI Tx >> agi_uniqueid: 1340616655.76
<SIP/139255423-0000004c>AGI Tx >> agi_version: 10.5.0
<SIP/139255423-0000004c>AGI Tx >> agi_callerid: 139255
<SIP/139255423-0000004c>AGI Tx >> agi_calleridname: unknown
<SIP/139255423-0000004c>AGI Tx >> agi_callingpres: 0
<SIP/139255423-0000004c>AGI Tx >> agi_callingani2: 0
<SIP/139255423-0000004c>AGI Tx >> agi_callington: 0
<SIP/139255423-0000004c>AGI Tx >> agi_callingtns: 0
<SIP/139255423-0000004c>AGI Tx >> agi_dnid: 629999999
<SIP/139255423-0000004c>AGI Tx >> agi_rdnis: unknown
<SIP/139255423-0000004c>AGI Tx >> agi_context: customer
<SIP/139255423-0000004c>AGI Tx >> agi_extension: 0034629999999
<SIP/139255423-0000004c>AGI Tx >> agi_priority: 8
<SIP/139255423-0000004c>AGI Tx >> agi_enhanced: 0.0
<SIP/139255423-0000004c>AGI Tx >> agi_accountcode: 704741
<SIP/139255423-0000004c>AGI Tx >> agi_threadid: 1104279872
<SIP/139255423-0000004c>AGI Tx >>
<SIP/139255423-0000004c>AGI Rx << GET VARIABLE "CDR(src)"
<SIP/139255423-0000004c>AGI Tx >> 200 result=1 (139255423)
<SIP/139255423-0000004c>AGI Rx << SET VARIABLE "CDR(accountcode)" "704741"
<SIP/139255423-0000004c>AGI Tx >> 200 result=1
<SIP/139255423-0000004c>AGI Rx << SET VARIABLE "CDR(dest_id)" "507"
<SIP/139255423-0000004c>AGI Tx >> 200 result=1
<SIP/139255423-0000004c>AGI Rx << SET VARIABLE "CDR(routeplan)" "11261"
<SIP/139255423-0000004c>AGI Tx >> 200 result=1
<SIP/139255423-0000004c>AGI Rx << SET VARIABLE "CDR(carrier)" "69"
<SIP/139255423-0000004c>AGI Tx >> 200 result=1
<SIP/139255423-0000004c>AGI Rx << EXEC "Dial" "SIP/100034629999999 at x.x.x.x"
-- AGI Script Executing Application: (Dial) Options:
(SIP/100034629999999 at x.x.x.x)
== Using SIP RTP CoS mark 5
-- Called SIP/100034629999999 at 193.17.66.71
-- SIP/193.17.66.71-0000004d is making progress passing it to
SIP/139255423-0000004c
-- SIP/193.17.66.71-0000004d is ringing
-- SIP/193.17.66.71-0000004d is making progress passing it to
SIP/139255423-0000004c
-- SIP/193.17.66.71-0000004d answered SIP/139255423-0000004c
-- Executing [h at customer:1] Set("SIP/139255423-0000004c",
"CDR(q931)=16") in new stack
-- Executing [h at customer:2] Set("SIP/139255423-0000004c",
"CDR(userfield)={"agi":"","a-leg-id":"2118d872-305e-4bb4-8c47-30e1514cb934","b-leg-id":"36b232e73ac326bd0407b1594627c589 at y.y.y.y:5060"}")
in new stack
<SIP/139255423-0000004c>AGI Tx >> 200 result=-1
<SIP/139255423-0000004c>AGI Tx >> HANGUP
<SIP/139255423-0000004c>AGI Rx << GET VARIABLE "HANGUPCAUSE"
<SIP/139255423-0000004c>AGI Tx >> 200 result=1 (16)
<SIP/139255423-0000004c>AGI Rx << GET VARIABLE "Q16"
<SIP/139255423-0000004c>AGI Tx >> 200 result=1 (0)
<SIP/139255423-0000004c>AGI Rx << SET VARIABLE "AJ_AGISTATUS" "SUCCESS"
<SIP/139255423-0000004c>AGI Tx >> 200 result=1
-- <SIP/139255423-0000004c>AGI Script agi://localhost/auth completed,
returning 4
<SIP/139255423-0000004c>AGI Tx >> HANGUP
== Spawn extension (customer, 0034629999999, 8) exited non-zero on
'SIP/139255423-0000004c'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120625/a6f9d9ea/attachment.htm>
More information about the asterisk-users
mailing list