[asterisk-users] Re : Controlling calls
Hello Steve, Thanks again for the effort. I tried your dialplan like this in my extention: exten= 777,1, Goto(absolute-timeout-test,777,1) [absolute-timeout-test] exten = T,1, verbose(1,[${CONTEXT}:${EXTEN}]) exten = T,n, hangup() exten = h,1, verbose(1,[${CONTEXT}:${EXTEN}]) exten = h,n, hangup() exten = 777,1, verbose(1,[${CONTEXT}:${EXTEN}]) exten = 777,n, set(TIMEOUT(absolute)=10) exten = 777,n, dial(IAX2/400) exten = 777,n, hangup() Then user IAX/200 calls 777, here is my output: debian*CLI set verbose 3 Verbosity is at least 3 -- Accepting AUTHENTICATED call from 192.168.1.34: requested format = ulaw, requested prefs = (), actual format = ulaw, host prefs = (ulaw|alaw), priority = mine -- Executing [...@iax:1] Dial(IAX2/200-7016, IAX2/777|60) in new stack [Jun 7 18:52:16] WARNING[4264]: chan_iax2.c:3034 create_addr: No such host: 777 [Jun 7 18:52:16] WARNING[4264]: app_dial.c:1183 dial_exec_full: Unable to create channel of type 'IAX2' (cause 3 - No route to destination) == Everyone is busy/congested at this time (1:0/0/1) == Auto fallthrough, channel 'IAX2/200-7016' status is 'CHANUNAVAIL' I do not know why it is printing No such host:777 For the STDOUT (System.out.println) i was watching what the AgiServer printing as information. Regrads De : Steve Edwards asterisk@sedwards.com À : Asterisk Users Mailing List - Non-Commercial Discussion asterisk-users@lists.digium.com Envoyé le : Lun 7 juin 2010, 17h 52min 09s Objet : Re: [asterisk-users] Controlling calls On Mon, 7 Jun 2010, Adil Zaaraoui wrote: I tried your statement in my extension like this: (context or dialplan would be more correct than extension.) 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. This is unexpected. When the absolute timer expires, the call should jump to the T extension in the context. If there isn't a T extension, the call should hang up. Please use a goto(absolute-timeout-test,777,1) to execute the following context with the CLI verbosity set to at least 3: [absolute-timeout-test] exten = T,1, verbose(1,[${CONTEXT}:${EXTEN}]) exten = T,n, hangup() exten = h,1, verbose(1,[${CONTEXT}:${EXTEN}]) exten = h,n, hangup() exten = 777,1, verbose(1,[${CONTEXT}:${EXTEN}]) exten = 777,n, set(TIMEOUT(absolute)=10) exten = 777,n, dial(sip/201) exten = 777,n, hangup() And compare your console output to: [absolute-timeout-test:777] -- Executing Set(SIP/501-090e8700, TIMEOUT(absolute)=10) in new stack -- Channel will hangup at 2010-06-07 15:34:29 UTC. -- Executing Dial(SIP/501-090e8700, sip/201) in new stack -- Called 201 -- SIP/201-0910b9a8 is ringing -- SIP/201-0910b9a8 answered SIP/501-090e8700 -- Attempting native bridge of SIP/501-090e8700 and SIP/201-0910b9a8 == Spawn extension (absolute-timeout-test, 777, 3) exited non-zero on 'SIP/501-090e8700' -- Executing Verbose(SIP/501-090e8700, 1|[absolute-timeout-test:T]) in new stack [absolute-timeout-test:T] -- Executing Hangup(SIP/501-090e8700, ) in new stack == Spawn extension (absolute-timeout-test, T, 2) exited non-zero on 'SIP/501-090e8700' -- Executing Verbose(SIP/501-090e8700, 1|[absolute-timeout-test:h]) in new stack [absolute-timeout-test:h] -- Executing Hangup(SIP/501-090e8700, ) in new stack == Spawn extension (absolute-timeout-test, h, 2) exited non-zero on 'SIP/501-090e8700' I'm calling from SIP/501 to SIP/201, but your output should be similar. While following the console output, I realize this solution may not do what you want. The absolute timer starts counting when it is set, not when the peer answers the call. I don't know if this difference is important to your application. Looking at the dial application options again, there is S(x) - Hang up the call after 'x' seconds *after* the called party has answered the call. This may be more appropriate for you. I'd still recommend looking up the peer and duration in the AGI, set channel variables, and then do the dial command in the dialplan. 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
Re: [asterisk-users] Re : Controlling calls
On Mon, 7 Jun 2010, Adil Zaaraoui wrote: Hello Steve, Thanks again for the effort. I tried your dialplan like this in my extention: exten= 777,1, Goto(absolute-timeout-test,777,1) [absolute-timeout-test] exten = T,1, verbose(1,[${CONTEXT}:${EXTEN}]) exten = T,n, hangup() exten = h,1, verbose(1,[${CONTEXT}:${EXTEN}]) exten = h,n, hangup() exten = 777,1, verbose(1,[${CONTEXT}:${EXTEN}]) exten = 777,n, set(TIMEOUT(absolute)=10) exten = 777,n, dial(IAX2/400) exten = 777,n, hangup() Then user IAX/200 calls 777, here is my output: debian*CLI set verbose 3 Verbosity is at least 3 -- Accepting AUTHENTICATED call from 192.168.1.34: requested format = ulaw, requested prefs = (), actual format = ulaw, host prefs = (ulaw|alaw), priority = mine -- Executing [...@iax:1] Dial(IAX2/200-7016, IAX2/777|60) in new stack [Jun 7 18:52:16] WARNING[4264]: chan_iax2.c:3034 create_addr: No such host: 777 I wrote goto(absolute-timeout-test,777,1) not dial(IAX2/777|60) You don't have a peer named 777 in iax.conf do you? The 777 has no special meaning, I just used it because you used it in your first post. Did you catch the note about the dial S option in my previous post? -- Thanks in advance, - Steve Edwards sedwa...@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
[asterisk-users] Re : Controlling calls
Thank you for the reply. 1- yes i need to call my agi script; because i have to process some tasks with my DBMS on the caller. 2- yes it is my first script, While very simple, the AGI protocol is easy to violate i did not get your meaning. So do you have a perfect solution? Best regards De : Steve Edwards asterisk@sedwards.com À : Asterisk Users Mailing List - Non-Commercial Discussion asterisk-users@lists.digium.com Envoyé le : Dim 6 juin 2010, 4h 47min 59s Objet : Re: [asterisk-users] 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. 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(6); 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 sedwa...@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 -- _ -- 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
[asterisk-users] Re : Controlling calls
Thank you for the reply. 1- yes i need to call my agi script; because i have to process some tasks with my DBMS on the caller. 2- yes it is my first script, While very simple, the AGI protocol is easy to violate i did not get your meaning. 5-yes i agree with you, is there an other solution? So do you have a perfect solution to handle this? I am new to agi for this i need the help from you Best regards De : Steve Edwards asterisk@sedwards.com À : Asterisk Users Mailing List - Non-Commercial Discussion asterisk-users@lists.digium.com Envoyé le : Dim 6 juin 2010, 4h 47min 59s Objet : Re: [asterisk-users] 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. 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(6); 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 sedwa...@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 -- _ -- 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
Re: [asterisk-users] Re : Controlling calls
Un-top-posting... 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, Adil Zaaraoui wrote: 1- yes i need to call my agi script; because i have to process some tasks with my DBMS on the caller. Can you set an absolute timeout either in your script or before you call your script? 2- yes it is my first script, While very simple, the AGI protocol is easy to violate i did not get your meaning. The AGI protocol is implemented by issuing requests and receiving responses via STDOUT and STDIN respectively. (FastAGI uses network sockets.) Most programmer's first fail is not reading the AGI environment from STDIN first. Next, they fail to realize that for every request, they must read the response. Lastly, they try to debug their AGI by reading something from STDIN or writing something to STDOUT, not remembering that STDIN and STDOUT are connected to Asterisk, not their console. I always recommend that programmers use an existing library rather than developing their own. The chance of success is much higher. Most AGI problems I have seen (mine and others) can be resolved by understanding the above and enabling AGI debugging on the console and observing the output. So do you have a perfect solution? There are no perfect solutions :) Setting an absolute timeout sounds pretty good to me. It's simple and obvious. You may consider setting a channel variable with the peer dial string in your AGI and keeping the dial command in the dialplan. It seems like a better approach to me, but then I've only had 1 cup of tea this morning and can't explain why coherently. -- Thanks in advance, - Steve Edwards sedwa...@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
[asterisk-users] Re : Controlling calls
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. -- _ -- 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
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 sedwa...@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