Hello folks, I want to write an AGI script doing this: 1-user call a number. 2-asterisk call the agi script 3-the script dial the peer 4-if the call is answered, let the call up for 1min 5-then the script hangs up the channel. I tried either in php or in java but no success. In java i did this: ////////////// exec("Dial", "IAX2/400"); boolean t=true; while(t){ if(getChannel().getChannelStatus()==6)t=false; } wait(60000); hangup(); ////////// in my extension.conf: exten =>777,1,AGI(agi://localhost/sc.agi) the script is running but it does not hangup. Second solution,i tried this : exten => 777,1,Dial(IAX2/400,G(myscript)) exten =>777,n(myscript),AGI(agi://localhost/sc.agi) in sc.agi in this time i do not call exec("Dial","IAX2/400") statment; but the audio stops, no ringing. Do you have any solution. thanks for your help -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100605/f14dc573/attachment.htm
On Sat, 5 Jun 2010, Adil Zaaraoui wrote:> I want to write an AGI script doing this: > > 1-user call a number. > 2-asterisk call the agi script > 3-the script dial the peer > 4-if the call is answered, let the call up for 1min > 5-then the script hangs up the channel. > > I tried either in php or in java but no success. > > In java i did this: > > ////////////// > exec("Dial", "IAX2/400"); > boolean t=true; > while(t){ > if(getChannel().getChannelStatus()==6)t=false; > } > wait(60000); > hangup(); > ////////// > in my extension.conf: > exten =>777,1,AGI(agi://localhost/sc.agi) > the script is running but it does not hangup. > > Second solution,i tried this : > exten => 777,1,Dial(IAX2/400,G(myscript)) > exten =>777,n(myscript),AGI(agi://localhost/sc.agi) > > in sc.agi in this time i do not call exec("Dial","IAX2/400") statment; > but the audio stops, no ringing. > > Do you have any solution.0) Please post requests with a more meaningful subject. There are lots of ways to control calls. 1) Do you need to call an AGI? Can you use an absolute timeout of 1 minute? 2) Is this your first AGI? While very simple, the AGI protocol is easy to violate. 3) You are executing "FastAGI." Is this required by the Java package you are using? 4) I'm just a 1.2 weenie and I've never used "G," but won't the "G" option transfer the calling party to "myscript" and the called party to "myscript+1?" 5) Not related to your issue, but "spinning" on the channel status doesn't look like a good idea. Adding a "wait(x)" to your while loop may help with CPU resource consumption. 6) More detail like what version of Asterisk and some console output with AGI debugging enabled may help. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
On Sun, 6 Jun 2010, Adil Zaaraoui wrote:> i do not need absolute timeout, i have to get from my database how?many > minutes can the caller communicate; so in my script run the dial command > (fire the call), controlling the elapsed time if the channel is > answered, then hanging up the channel.Can you lookup the peer and the remaining minutes in your AGI, set these values in channel variables and then set the timeout and dial your peer in your dialplan? -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
Yes i can get the user remaining minutes from my database, the scrips runs; but when i run exec("Dial","IAX2/400") then geting the channelStatus if is answer it does not hangup using either getChannel().hangup() or just hangup(). note: when running Dial from my script, it blocks for a period about 13seconds then the program continue to the next statment. I think you get what i want to achieve. dialing from the script, if the channel is answered, set a timer, if the caller consumed his minutes, from the script i hangup. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100606/6a5a2748/attachment.htm
On Sat, 5 Jun 2010, Adil Zaaraoui wrote:> I want to write an AGI script doing this: > > 1-user call a number. > 2-asterisk call the agi script > 3-the script dial the peer > 4-if the call is answered, let the call up for 1min > 5-then the script hangs up the channel.On Sun, 6 Jun 2010, Steve Edwards wrote:> Can you lookup the peer and the remaining minutes in your AGI, set these > values in channel variables and then set the timeout and dial your peer > in your dialplan?On Sun, 6 Jun 2010, Adil Zaaraoui wrote:> Yes i can get the user remaining minutes from my database, the scrips > runs; but when i run exec("Dial","IAX2/400") then geting the > channelStatus if is answer it does not hangup using either > getChannel().hangup() or just hangup(). > > note: when running Dial from my script, it blocks for a period about > 13seconds then the program continue to the next statment.Are you saying that when you execute the dial application from your AGI Asterisk dials the peer and when peer answers they get dead air for 13 seconds before being bridged with the caller?> I think you get what i want to achieve. dialing from the script, if the > channel is answered, set a timer, if the caller consumed his minutes, > from the script i hangup.Did you try setting channel variables in your AGI and then doing an absolute timeout and the dial command in the dialplan? What happened? What happens if you try something like this: exten = 777,n, set(TIMEOUT(absolute)=30) exten = 777,n, dial(iax2/400) exten = 777,n, hangup() What is supposed to happen if the call is not answered? -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
Hello, thanks for your help and you time, I tried your statement in my extension like this: ? exten = 777,n,? ? ? ? ? ? ? ? ? set(TIMEOUT(absolute)=10) ??exten = 777,n,? ? ? ? ? ? ? ? ? dial(iax2/400) ??exten = 777,n,? ? ? ? ? ? ? ? ? hangup() If peer (400) answers the call the call persists, no autohangup is made after 10 senconds (absolute timeout), but the if peer does not hangup, it rings for 10 seconds and stops. "Are you saying that when you execute the dial application from your AGI Asterisk dials the peer and when peer answers they get dead air for 13 seconds before being bridged with the caller?" No, the communication is up we hear each other, but the satament System.out.println("after dial app") which is just after exec("dial.... is executed after about 13 seconds, and sometimes not, the dial blocks the script to continue. How to set the channel variable in the AGI script?? Many thanks ? ________________________________ De : Steve Edwards <asterisk.org at sedwards.com> ? : Asterisk Users Mailing List - Non-Commercial Discussion <asterisk-users at lists.digium.com> Envoy? le : Lun 7 juin 2010, 0h 37min 36s Objet?: Re: [asterisk-users] Re : Controlling calls On Sat, 5 Jun 2010, Adil Zaaraoui wrote:> I want to write an AGI script doing this: > > 1-user call a number. > 2-asterisk call the agi script > 3-the script dial the peer > 4-if the call is answered, let the call up for 1min > 5-then the script hangs up the channel.On Sun, 6 Jun 2010, Steve Edwards wrote:> Can you lookup the peer and the remaining minutes in your AGI, set these > values in channel variables and then set the timeout and dial your peer > in your dialplan?On Sun, 6 Jun 2010, Adil Zaaraoui wrote:> Yes i can get the user remaining minutes from my database, the scrips > runs; but when i run exec("Dial","IAX2/400") then geting the > channelStatus if is answer it does not hangup using either > getChannel().hangup() or just hangup(). > > note: when running Dial from my script, it blocks for a period about > 13seconds then the program continue to the next statment.Are you saying that when you execute the dial application from your AGI Asterisk dials the peer and when peer answers they get dead air for 13 seconds before being bridged with the caller?> I think you get what i want to achieve. dialing from the script, if the > channel is answered, set a timer, if the caller consumed his minutes, > from the script i hangup.Did you try setting channel variables in your AGI and then doing an absolute timeout and the dial command in the dialplan? What happened? What happens if you try something like this: ? ? ? ? exten = 777,n,? ? ? ? ? ? ? ? ? set(TIMEOUT(absolute)=30) ? ? ? ? exten = 777,n,? ? ? ? ? ? ? ? ? dial(iax2/400) ? ? ? ? exten = 777,n,? ? ? ? ? ? ? ? ? hangup() What is supposed to happen if the call is not answered? -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards? ? ? sedwards at sedwards.com? ? ? Voice: +1-760-468-3867 PST Newline? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Fax: +1-760-731-3000 -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: ? ? ? ? ? ? ? http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: ? http://lists.digium.com/mailman/listinfo/asterisk-users -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100607/92390a61/attachment.htm