<span class="gD">Alejandro,<br><br></span>Try the 'g' option to Dial():<br><br><a href="http://www.voip-info.org/wiki/view/Asterisk+cmd+Dial">http://www.voip-info.org/wiki/view/Asterisk+cmd+Dial</a><br><ul><li> <b>g</b>: When the called party hangs up, continue to execute commands in the current context at the next priority</li>
</ul><br><br><div class="gmail_quote">On 25 June 2012 20:17, Alejandro Recarey <span dir="ltr"><<a href="mailto:alexrecarey@gmail.com" target="_blank">alexrecarey@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<div><br></div><div>I am trying to control the whole call using a FastAGI script. To that effect I launch a FastAGI script (written with asterisk-java).</div>
<div><br></div><div>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.</div>
<div><br></div><div>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. </div>
<div><br></div><div>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.</div>
<div><br></div><div>Is there any way to get that behaviour?</div><div><br></div><div>Regards,</div><div><br></div><div>Alex</div><div><br></div><div><br></div><div><div><br></div><div>"Entering customer extension"</div>
<div> -- Executing [629999999@customer:2] Verbose("SIP/139255423-0000004c", "5,"Dialed - 629999999"") in new stack</div><div> > "Dialed - 629999999"</div><div> -- Executing [629999999@customer:3] Set("SIP/139255423-0000004c", "origincontext=customer") in new stack</div>
<div> -- Executing [629999999@customer:4] Goto("SIP/139255423-0000004c", "transform,629999999,1") in new stack</div><div> -- Goto (transform,629999999,1)</div><div> -- Executing [629999999@transform:1] Goto("SIP/139255423-0000004c", "customer,0034629999999,transform") in new stack</div>
<div> -- Goto (customer,0034629999999,5)</div><div> -- Executing [0034629999999@customer:5] Verbose("SIP/139255423-0000004c", "5,"New dialnum - 0034629999999"") in new stack</div><div> > "New dialnum - 0034629999999"</div>
<div> -- Executing [0034629999999@customer:6] Set("SIP/139255423-0000004c", "CDR(server)=7") in new stack</div><div> -- Executing [0034629999999@customer:7] Set("SIP/139255423-0000004c", "CDR(srcip)=") in new stack</div>
<div> -- Executing [0034629999999@customer:8] AGI("SIP/139255423-0000004c", "agi://localhost/auth") in new stack</div><div>AGI Tx >> agi_network: yes</div><div>AGI Tx >> agi_network_script: auth</div>
<div><SIP/139255423-0000004c>AGI Tx >> agi_request: agi://localhost/auth</div><div><SIP/139255423-0000004c>AGI Tx >> agi_channel: SIP/139255423-0000004c</div><div><SIP/139255423-0000004c>AGI Tx >> agi_language: es</div>
<div><SIP/139255423-0000004c>AGI Tx >> agi_type: SIP</div><div><SIP/139255423-0000004c>AGI Tx >> agi_uniqueid: 1340616655.76</div><div><SIP/139255423-0000004c>AGI Tx >> agi_version: 10.5.0</div>
<div><SIP/139255423-0000004c>AGI Tx >> agi_callerid: 139255</div><div><SIP/139255423-0000004c>AGI Tx >> agi_calleridname: unknown</div><div><SIP/139255423-0000004c>AGI Tx >> agi_callingpres: 0</div>
<div><SIP/139255423-0000004c>AGI Tx >> agi_callingani2: 0</div><div><SIP/139255423-0000004c>AGI Tx >> agi_callington: 0</div><div><SIP/139255423-0000004c>AGI Tx >> agi_callingtns: 0</div>
<div><SIP/139255423-0000004c>AGI Tx >> agi_dnid: 629999999</div><div><SIP/139255423-0000004c>AGI Tx >> agi_rdnis: unknown</div><div><SIP/139255423-0000004c>AGI Tx >> agi_context: customer</div>
<div><SIP/139255423-0000004c>AGI Tx >> agi_extension: 0034629999999</div><div><SIP/139255423-0000004c>AGI Tx >> agi_priority: 8</div><div><SIP/139255423-0000004c>AGI Tx >> agi_enhanced: 0.0</div>
<div><SIP/139255423-0000004c>AGI Tx >> agi_accountcode: 704741</div><div><SIP/139255423-0000004c>AGI Tx >> agi_threadid: 1104279872</div><div><SIP/139255423-0000004c>AGI Tx >> </div><div>
<SIP/139255423-0000004c>AGI Rx << GET VARIABLE "CDR(src)"</div><div><SIP/139255423-0000004c>AGI Tx >> 200 result=1 (139255423)</div><div><SIP/139255423-0000004c>AGI Rx << SET VARIABLE "CDR(accountcode)" "704741"</div>
<div><SIP/139255423-0000004c>AGI Tx >> 200 result=1</div><div><SIP/139255423-0000004c>AGI Rx << SET VARIABLE "CDR(dest_id)" "507"</div><div><SIP/139255423-0000004c>AGI Tx >> 200 result=1</div>
<div><SIP/139255423-0000004c>AGI Rx << SET VARIABLE "CDR(routeplan)" "11261"</div><div><SIP/139255423-0000004c>AGI Tx >> 200 result=1</div><div><SIP/139255423-0000004c>AGI Rx << SET VARIABLE "CDR(carrier)" "69"</div>
<div><SIP/139255423-0000004c>AGI Tx >> 200 result=1</div><div><SIP/139255423-0000004c>AGI Rx << EXEC "Dial" "SIP/100034629999999@x.x.x.x"</div><div> -- AGI Script Executing Application: (Dial) Options: (SIP/100034629999999@x.x.x.x)</div>
<div> == Using SIP RTP CoS mark 5</div><div> -- Called SIP/<a href="mailto:100034629999999@193.17.66.71" target="_blank">100034629999999@193.17.66.71</a></div><div> -- SIP/193.17.66.71-0000004d is making progress passing it to SIP/139255423-0000004c</div>
<div> -- SIP/193.17.66.71-0000004d is ringing </div><div> -- SIP/193.17.66.71-0000004d is making progress passing it to SIP/139255423-0000004c</div><div> -- SIP/193.17.66.71-0000004d answered SIP/139255423-0000004c</div>
<div> -- Executing [h@customer:1] Set("SIP/139255423-0000004c", "CDR(q931)=16") in new stack</div><div> -- Executing [h@customer:2] Set("SIP/139255423-0000004c", "CDR(userfield)={"agi":"","a-leg-id":"2118d872-305e-4bb4-8c47-30e1514cb934","b-leg-id":"36b232e73ac326bd0407b1594627c589@y.y.y.y:5060"}") in new stack</div>
<div><SIP/139255423-0000004c>AGI Tx >> 200 result=-1</div><div><SIP/139255423-0000004c>AGI Tx >> HANGUP</div><div><SIP/139255423-0000004c>AGI Rx << GET VARIABLE "HANGUPCAUSE"</div>
<div><SIP/139255423-0000004c>AGI Tx >> 200 result=1 (16)</div><div><SIP/139255423-0000004c>AGI Rx << GET VARIABLE "Q16"</div><div><SIP/139255423-0000004c>AGI Tx >> 200 result=1 (0)</div>
<div><SIP/139255423-0000004c>AGI Rx << SET VARIABLE "AJ_AGISTATUS" "SUCCESS"</div><div><SIP/139255423-0000004c>AGI Tx >> 200 result=1</div><div> -- <SIP/139255423-0000004c>AGI Script agi://localhost/auth completed, returning 4</div>
<div><SIP/139255423-0000004c>AGI Tx >> HANGUP</div><div> == Spawn extension (customer, 0034629999999, 8) exited non-zero on 'SIP/139255423-0000004c'</div></div>
<br>--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
<a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></blockquote></div><br><br clear="all"><br>-- <br>David Cunningham, Voisonics<br>
<a href="http://voisonics.com/" target="_blank">http://voisonics.com/</a><br>US toll-free: <a href="tel:%2B1%20888%20842%202720" value="+18888422720" target="_blank">+1 888 842 2720</a><br>UK: <a href="tel:%2B44%20%280%29%2020%203298%201642" value="+442032981642" target="_blank">+44 (0) 20 3298 1642</a><br>
Australia: <a href="tel:%2B61%20%280%29%202%208063%209019" value="+61280639019" target="_blank">+61 (0) 2 8063 9019</a><br><br>