Thread: [Asterisk-java-devel] How to Cancel a Dial command
Brought to you by:
srt
From: Jeryes . <je...@vo...> - 2012-01-03 21:24:15
|
Hi All, I'm using java fast-agi protocol, and I'm dialing to new destinations based on the existing channel: * channel.exec("Dial","SIP/extension1")* and I'm facing a problem to cancel that dial if the call sufers a timeout, and originate new call to other destination. Do someone have faced that problem or have any idea to implement this scenario? I'm working with the versions below: asterisk 1.6.2.22 asterisk-java 1.0.0 Thanks in advance! Jeryes |
From: Yves A. <yv...@gm...> - 2012-01-03 21:46:23
|
Hi, happy new year, welcome to the list and congrats... you´re the first in 2012! reason enough for me to flood you with solutions, but.... you gave too little info...at least for me...: - a few more lines of code would be helpful... full code would be best + part of the dialplan where you call the agi.. - what is your objective? - any exceptions / interesting logs? - how do you define timeout? I don´t see any at your dial command. - what did you try so far and what was the result? regards, yves Am 03.01.2012 21:55, schrieb Jeryes .: > Hi All, > > I'm using java fast-agi protocol, > and I'm dialing to new destinations based on the existing channel: > * > channel.exec("Dial","SIP/extension1")* > > and I'm facing a problem to cancel that dial if the call sufers a > timeout, and originate new call to other destination. Do someone have > faced that problem or have any idea to implement this scenario? > > I'm working with the versions below: > asterisk 1.6.2.22 > asterisk-java 1.0.0 > > Thanks in advance! > > Jeryes > > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > > > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel |
From: Jeryes . <je...@vo...> - 2012-01-04 21:23:23
|
Hi Yves, Happy new year and thanks for your quick reply!! Actually, I fixed the problem, sorry it was my fault... I'm working on an application based on fast-agi, and I've created an AsteriskServer that implements the interface BaseAgiScript, to receive and process calls from Asterisk. After receive a new call, the application dial to some destination (e.g. user1), and in some situation, like timeout of dialing, the application must cancel that Dial and create a new one to other destination, but I was doing in a wrong way, I was looking for a way to Cancel the Dial, and I guess that I can't do it, so I fixed the problem adding the timeout value in the Dial command, now the Asterisk is sending that Cancel when the timeout expires, and it's working: Example code of implementation: public class AsteriskServer extends BaseAgiScript { /** * The service method is called whenever AgiAsteriskServer receive a new * incoming AgiRequest. */ public void service(AgiRequest request, AgiChannel channel) throws AgiException { //Some code try { channel.exec("Dial", "SIP/user1, *20*"); } catch (Exception e) { //do something } finally { //do something } //Some code } } and *20* is the timeout to that destination. Now I'm facing another problem, the command Dial is not running on background, it keeps the Thread that executed the command in wait until the Dial sufers some dinconnection event (4xx, 5xx or 6xx) So do I need to create a new Thread to execute the command Dial? And is there another way besides the CLI to originate a new Call using fast-agi? Thank you!! Best regards Jeryes 2012/1/3 Yves A. <yv...@gm...> > Hi, > > happy new year, welcome to the list and congrats... you´re the first in > 2012! > reason enough for me to flood you with solutions, but.... > > you gave too little info...at least for me...: > - a few more lines of code would be helpful... full code would be best + > part of the dialplan where you call the agi.. > - what is your objective? > - any exceptions / interesting logs? > - how do you define timeout? I don´t see any at your dial command. > - what did you try so far and what was the result? > > regards, > yves > > > Am 03.01.2012 21:55, schrieb Jeryes .: > > Hi All, > > I'm using java fast-agi protocol, > and I'm dialing to new destinations based on the existing channel: > * > channel.exec("Dial","SIP/extension1")* > > and I'm facing a problem to cancel that dial if the call sufers a timeout, > and originate new call to other destination. Do someone have faced that > problem or have any idea to implement this scenario? > > I'm working with the versions below: > asterisk 1.6.2.22 > asterisk-java 1.0.0 > > Thanks in advance! > > Jeryes > > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/joinhttp://p.sf.net/sfu/intel-appdev > > > > _______________________________________________ > Asterisk-java-devel mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > |
From: Yves A. <yv...@gm...> - 2012-01-05 10:46:09
|
Hi, unfortunately I do not understand you fully. What do you mean with "sufer"? What is the Event 4xx, 5xx ...? Please explain. And explain exactly what your Objective is. When To call who, And so on. I dont understand what you mean by cancel the dial on timeout...? After a timeout the dial IS finished... cancelling for me would be something like interrupting a running dial command. At First Reading it Looks like you're needing Something like a Queue...? Or an IVR? Regards, Yves Am 04.01.2012 um 22:23 schrieb "Jeryes ." <je...@vo...>: > Hi Yves, > > Happy new year and thanks for your quick reply!! > > Actually, I fixed the problem, sorry it was my fault... > > I'm working on an application based on fast-agi, and I've created an AsteriskServer that implements the interface BaseAgiScript, to receive and process calls from Asterisk. > After receive a new call, the application dial to some destination (e.g. user1), and in some situation, like timeout of dialing, the application must cancel that Dial and > create a new one to other destination, but I was doing in a wrong way, I was looking for a way to Cancel the Dial, and I guess that I can't do it, > so I fixed the problem adding the timeout value in the Dial command, now the Asterisk is sending that Cancel when the timeout expires, and it's working: > > Example code of implementation: > > public class AsteriskServer extends BaseAgiScript > { > > /** > * The service method is called whenever AgiAsteriskServer receive a new > * incoming AgiRequest. > */ > public void service(AgiRequest request, AgiChannel channel) throws AgiException > { > //Some code > > try > { > channel.exec("Dial", "SIP/user1, 20"); > > } catch (Exception e) { > //do something > } finally { > //do something > } > > //Some code > > } > } > > and 20 is the timeout to that destination. > > Now I'm facing another problem, the command Dial is not running on background, it keeps the Thread that executed the command in wait until the Dial sufers some dinconnection event (4xx, 5xx or 6xx) > So do I need to create a new Thread to execute the command Dial? > And is there another way besides the CLI to originate a new Call using fast-agi? > > > Thank you!! > > Best regards > Jeryes > > > 2012/1/3 Yves A. <yv...@gm...> > Hi, > > happy new year, welcome to the list and congrats... you´re the first in 2012! > reason enough for me to flood you with solutions, but.... > > you gave too little info...at least for me...: > - a few more lines of code would be helpful... full code would be best + part of the dialplan where you call the agi.. > - what is your objective? > - any exceptions / interesting logs? > - how do you define timeout? I don´t see any at your dial command. > - what did you try so far and what was the result? > > regards, > yves > > > Am 03.01.2012 21:55, schrieb Jeryes .: >> >> Hi All, >> >> I'm using java fast-agi protocol, >> and I'm dialing to new destinations based on the existing channel: >> >> channel.exec("Dial","SIP/extension1") >> >> and I'm facing a problem to cancel that dial if the call sufers a timeout, and originate new call to other destination. Do someone have faced that problem or have any idea to implement this scenario? >> >> I'm working with the versions below: >> asterisk 1.6.2.22 >> asterisk-java 1.0.0 >> >> Thanks in advance! >> >> Jeryes >> >> >> ------------------------------------------------------------------------------ >> Write once. Port to many. >> Get the SDK and tools to simplify cross-platform app development. Create >> new or port existing apps to sell to consumers worldwide. Explore the >> Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join >> http://p.sf.net/sfu/intel-appdev >> >> >> _______________________________________________ >> Asterisk-java-devel mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > ------------------------------------------------------------------------------ > Write once. Port to many. > Get the SDK and tools to simplify cross-platform app development. Create > new or port existing apps to sell to consumers worldwide. Explore the > Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join > http://p.sf.net/sfu/intel-appdev > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel |
From: Jeryes . <je...@vo...> - 2012-01-05 21:37:59
|
Hi Yves, I'm sorry, it was a little confusing... Let me try again... I'm working with fast-agi, implementing org.asterisk.java.fastagi.BaseAgiScript. Yes, I have an IVR, that receive a call (input channel) originated by some owner, the application basically plays a file and then dial to some destination, if that destination doesn't answer in 20 seconds (timeout), the IVR must dial to another one. I did that using the command Dial, and setting a timeout in that dial: int resultCode = channel.exec("Dial", "SIP/user1, *20*"); That is the way i found to establish a new outgoing connection on a channel, and then link it to the existing input channel. The problem that I am facing is to distinguish a timeout event from the disconnection of the owner, in other words, how can I differentiate when the FROM leg disconencts (sendig the CANCEL Request) from the timeout of the TO leg ou if the TO leg ignore (by replying 480, 486, 500, 503 or 603 for example) a call that is in DIALING state? Thanks for your time!!! []s Jeryes |
From: Yves A. <yv...@gm...> - 2012-01-05 21:59:09
|
I see. Try to implement a listener that listens to the asterisk-events. If you receive an unlink or hangup event, check, if the corresponding channel is your agi-source channel and if so, interrupt the outgoing dials, that were originated from here.. if your source channel is hung up, do not execute any commands on this channel as it would end up in an exception... regards, yves Am 05.01.2012 22:37, schrieb Jeryes .: > Hi Yves, > > I'm sorry, it was a little confusing... Let me try again... > > I'm working with fast-agi, implementing > org.asterisk.java.fastagi.BaseAgiScript. > > Yes, I have an IVR, that receive a call (input channel) originated by > some owner, the application basically plays a file and then dial to > some destination, if that destination doesn't answer in 20 seconds > (timeout), the IVR must dial to another one. I did that using the > command Dial, and setting a timeout in that dial: > > int resultCode = channel.exec("Dial", "SIP/user1, *20*"); > > That is the way i found to establish a new outgoing connection on a > channel, and then link it to the existing input channel. > > The problem that I am facing is to distinguish a timeout event from > the disconnection of the owner, in other words, how can I > differentiate when the FROM leg disconencts (sendig the CANCEL > Request) from the timeout of the TO leg ou if the TO leg ignore (by > replying 480, 486, 500, 503 or 603 for example) a call that is in > DIALING state? > > > Thanks for your time!!! > > []s > Jeryes > > > > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > > > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel |
From: Jeryes . <je...@vo...> - 2012-01-06 16:34:40
|
Yves, " if your source channel is hung up, do not execute any commands on this channel as it would end up in an exception..." that worked... if the channel is alive no exception will be thrown, and that is the characteristic of the FROM leg disconnection, or a disconnection of an established call, otherwise it is a timeout or an ignore sent from the TO leg. Thanks for your help!! []s Jeryes 2012/1/5 Yves A. <yv...@gm...> > I see. > Try to implement a listener that listens to the asterisk-events. If you > receive an unlink or hangup event, > check, if the corresponding channel is your agi-source channel and if so, > interrupt the outgoing dials, > that were originated from here.. > if your source channel is hung up, do not execute any commands on this > channel as it would end > up in an exception... > > regards, > yves > |
From: Yves A. <yv...@gm...> - 2012-01-06 20:55:55
|
Sure... but a listener would be more elegant, I think... yves Am 06.01.2012 17:34, schrieb Jeryes .: > Yves, > > " if your source channel is hung up, do not execute any commands on > this channel as it would end > up in an exception..." > > that worked... if the channel is alive no exception will be thrown, > and that is the characteristic of the FROM leg disconnection, or a > disconnection of an established call, otherwise it is a timeout or an > ignore sent from the TO leg. > > Thanks for your help!! > > []s > Jeryes > > > > > 2012/1/5 Yves A. <yv...@gm... <mailto:yv...@gm...>> > > I see. > Try to implement a listener that listens to the asterisk-events. > If you receive an unlink or hangup event, > check, if the corresponding channel is your agi-source channel and > if so, interrupt the outgoing dials, > that were originated from here.. > if your source channel is hung up, do not execute any commands on > this channel as it would end > up in an exception... > > regards, > yves > > > > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > > > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel |