asterisk-java-users Mailing List for Asterisk-Java Library (Page 167)
Brought to you by:
srt
You can subscribe to this list here.
2005 |
Jan
|
Feb
(8) |
Mar
(33) |
Apr
(36) |
May
(19) |
Jun
(21) |
Jul
(53) |
Aug
(30) |
Sep
(36) |
Oct
(34) |
Nov
(43) |
Dec
(72) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(123) |
Feb
(75) |
Mar
(86) |
Apr
(46) |
May
(41) |
Jun
(29) |
Jul
(76) |
Aug
(38) |
Sep
(39) |
Oct
(68) |
Nov
(16) |
Dec
(17) |
2007 |
Jan
(34) |
Feb
(18) |
Mar
(39) |
Apr
(30) |
May
(20) |
Jun
(10) |
Jul
(59) |
Aug
(54) |
Sep
(60) |
Oct
(22) |
Nov
(14) |
Dec
(10) |
2008 |
Jan
(34) |
Feb
(67) |
Mar
(65) |
Apr
(67) |
May
(60) |
Jun
(51) |
Jul
(88) |
Aug
(75) |
Sep
(47) |
Oct
(143) |
Nov
(54) |
Dec
(42) |
2009 |
Jan
(46) |
Feb
(80) |
Mar
(162) |
Apr
(159) |
May
(200) |
Jun
(34) |
Jul
(46) |
Aug
(59) |
Sep
(5) |
Oct
(35) |
Nov
(73) |
Dec
(30) |
2010 |
Jan
(23) |
Feb
(50) |
Mar
(8) |
Apr
(24) |
May
(19) |
Jun
(49) |
Jul
(56) |
Aug
(35) |
Sep
(26) |
Oct
(79) |
Nov
(39) |
Dec
(34) |
2011 |
Jan
(27) |
Feb
(22) |
Mar
(28) |
Apr
(12) |
May
(16) |
Jun
(19) |
Jul
(1) |
Aug
(64) |
Sep
(19) |
Oct
(11) |
Nov
(17) |
Dec
(12) |
2012 |
Jan
(6) |
Feb
(8) |
Mar
(15) |
Apr
(43) |
May
(41) |
Jun
(14) |
Jul
(32) |
Aug
(3) |
Sep
(4) |
Oct
(7) |
Nov
(11) |
Dec
(11) |
2013 |
Jan
(35) |
Feb
(11) |
Mar
(23) |
Apr
(25) |
May
(37) |
Jun
(47) |
Jul
(25) |
Aug
(21) |
Sep
|
Oct
(1) |
Nov
(9) |
Dec
|
2014 |
Jan
(26) |
Feb
(2) |
Mar
(18) |
Apr
(41) |
May
(7) |
Jun
(7) |
Jul
(24) |
Aug
(5) |
Sep
(6) |
Oct
(8) |
Nov
(9) |
Dec
(7) |
2015 |
Jan
(7) |
Feb
(15) |
Mar
(8) |
Apr
(12) |
May
(7) |
Jun
|
Jul
|
Aug
(5) |
Sep
(1) |
Oct
(3) |
Nov
(30) |
Dec
(3) |
2016 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
(4) |
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Stefan R. <sr...@re...> - 2005-12-12 07:57:17
|
Hi Jan, > According to the asterisk java webpage you just need to supply a=20 > fastagi.properties file on the classpath that looks like this: >=20 > bindPort =3D 1234 > poolSize =3D 20 >=20 > Everytime I start up *-J it still listens on the default port (4573). where did you put the fastagi.properties? Can you show us how you invoke Asterisk-Java? fastagi.properties must be in the "default package", i.e. the root package and not in any subdirectory. =3DStefan |
From: Jan du T. <jan...@de...> - 2005-12-12 06:55:37
|
Hi all. I need to bind asterisk java to a port other than the default 4573 port. According to the asterisk java webpage you just need to supply a fastagi.properties file on the classpath that looks like this: bindPort = 1234 poolSize = 20 Everytime I start up *-J it still listens on the default port (4573). What am I doing wrong? Any help will be appreciated. Thanks. |
From: Stefan R. <sr...@re...> - 2005-12-09 14:55:56
|
> My question is how do you extract this generated random number, so that=20 > one can succesfully hangup a channel using HangupAction? The easy solution is to use DefaultAsteriskManager to originate the call. Its originateCall method returns a Call object that contains the channel name. An other option is to listen for OriginateSuccess events (see the HelloEvents example on how to do that) and extract the channel name from that event. =3DStefan |
From: Jan du T. <jan...@de...> - 2005-12-09 14:46:58
|
Hi all. I used the OriginateAction to generate a call from the asterisk server on a channel to a certain extension. (Like the example on the tutorial page of the Asteriks-Java webpage@sourceforge.) The call is successfully generated. Now I want to hangup the call. I assume you want to use HangupAction. But hangupAction needs the exact channel id. A channel id for SIP for example will looks like this: "SIP/Jan-324bf". The first part of the channel id a person obviously know, because one configured OriginateAction with it. But Asterisks automatically generates a random number which is appended to the channel id to uniquley identify it. My question is how do you extract this generated random number, so that one can succesfully hangup a channel using HangupAction? Thank you. |
From: Stefan R. <sr...@re...> - 2005-12-09 13:21:36
|
Ines schrieb: > i want to be able to do call control, which means, when a call comes > threw asterisk, i want to be able to detect it, without answering, and > to be able to detect it's status (call alerting, connected... ) and then > control it and decide to answer or not, to forward it ... yes thanks for the clarification. Then you want to use the ManagerAPI. Have a look at the HelloManager and HelloEvents examples in the tutorial and at the javadocs for the classes in net.sf.asterisk.manager. Hope that helps. =Stefan |
From: Ines <mou...@ya...> - 2005-12-09 13:05:02
|
Hello, Thanks for your reply, i want to be able to do call control, which means, when a call comes threw asterisk, i want to be able to detect it, without answering, and to be able to detect it's status (call alerting, connected... ) and then control it and decide to answer or not, to forward it ... I hope you understand what i mean inés --------------------------------- Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez le ici ! |
From: Stefan R. <sr...@re...> - 2005-12-09 12:26:05
|
Hi, what functionality do you need for "call control"? you can use dial(), setExtension() and more with the AGI support of Asterisk-Java plus you can use the ManagerAPI with even more support like originate and redirect. =Stefan |
From: Ines <mou...@ya...> - 2005-12-09 11:22:31
|
hello, i need to do some call control in asterisk, using CCXML. i've been using Asterisk-Java, BaseAgiScript, but we can't do call control as there is only the method answer, i need to analyse a call when it gets threw asterisk. i found out that i can use JAsterisk but the probleme that there hardly no documentation on JAsterisk. has anyones used JAsterisk before ? or hoes somebody tried to do some call control in Asterisk ? if so, have u got any documentation? Thank's a lot Inés --------------------------------- Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez le ici ! |
From: Aparna R. <apa...@ya...> - 2005-11-28 10:36:30
|
hi Stefan, i removed the sendAction, as u suggested. it now works fine. thanks again. aparna Stefan Reuter <sr...@re...> wrote: Hi, try to remove the sendAction(new StatusAction()) and increase the 10 seconds to a larger value. If that doesnt work, i need additional information regarding the exact version of Asterisk you are running. =Stefan --------------------------------- Yahoo! Music Unlimited - Access over 1 million songs. Try it free. |
From: Stefan R. <sr...@re...> - 2005-11-28 10:24:27
|
Hi, try to remove the sendAction(new StatusAction()) and increase the 10 seconds to a larger value. If that doesnt work, i need additional information regarding the exact version of Asterisk you are running. =Stefan |
From: Stefan R. <sr...@re...> - 2005-11-27 18:10:46
|
Asterisk-Java 0.2, a Java control for the Asterisk PBX, has been released. The Asterisk-Java package consists of a set of Java classes that allow you to easily build Java applications that interact with an Asterisk PBX Server. Asterisk-Java supports both interfaces that Asterisk provides for this scenario: The FastAGI protocol and the Manager API. The 0.2 release focuses on the new features of the Asterisk 1.2 series though it still supports Asterisk 1.0.x. Since 0.2-rc2 some minor bugs have been fixed and support for several last minute additions to Asterisk 1.2 has been added. Asterisk-Java is used in several commercial environments and by the following Open Source projects: * Asterisk-IM A plugin for the Jive Messenger XMPP (jabber) server. It provides integrated presence between your IM client and phone, notification of incoming calls by IM and originate calls from supported IM clients. * Asterisk Desktop Manager (ADM) A desktop application that will allow for automatic on-call volume reduction, one click dial from clipboard, integrated phonebook and more. Asterisk-Java is available under Apache 2.0 license at http://www.asteriskjava.org |
From: Aparna R. <apa...@ya...> - 2005-11-25 15:32:50
|
Hi Stefan, Thnx for ur reply.The PeerStatusEvent now works. but before i get the name of the peer that just registered, i get a 'java.lang.InterruptedException : sleep interrupted'. But.. if i wait for long, the name of the peer that registered is displayed. Also the Connection doesn't logoff.! This is my Code: import java.io.IOException; import net.sf.asterisk.manager.AuthenticationFailedException; import net.sf.asterisk.manager.ManagerConnection; import net.sf.asterisk.manager.ManagerConnectionFactory; import net.sf.asterisk.manager.ManagerEventHandler; import net.sf.asterisk.manager.TimeoutException; import net.sf.asterisk.manager.action.StatusAction; import net.sf.asterisk.manager.event.ManagerEvent; public class HelloEvents implements ManagerEventHandler { private ManagerConnection managerConnection; public HelloEvents() throws IOException { ManagerConnectionFactory factory = new ManagerConnectionFactory(); this.managerConnection = factory.getManagerConnection("localhost", "manager", "pa55w0rd"); } public void run() throws IOException, AuthenticationFailedException, TimeoutException, InterruptedException { // register for events managerConnection.addEventHandler(this); // connect to Asterisk and log in managerConnection.login(); // request channel state managerConnection.sendAction(new StatusAction()); // wait 10 seconds for events to come in Thread.sleep(10000); // and finally log off and disconnect managerConnection.logoff(); } public void handleEvent(ManagerEvent event) { if (event instanceof PeerStatusEvent) { String peerName= ((PeerStatusEvent) event).getPeer(); System.out.println(peerName+ " has just now registered!"); } } public static void main(String[] args) throws Exception { HelloEvents helloEvents; helloEvents = new HelloEvents(); helloEvents.run(); } } kindly tel me if I'm going wrong somewhere. Thanks n regards Aparna -------------------------------------------- Hi all, I'm completely new to Java and need help n guidance in using asterisk-java. I would like to get the name of the Peer from asterisk , when it registers. how shouild i go abt implementing this? i know i shd luk into PeerStatusEvent. but being new to Java, i would like some sample code to help me with. kindly guide. thanks n regards aparna --------------------------------- Yahoo! DSL Something to write home about. Just $16.99/mo. or less |
From: Stefan R. <sr...@re...> - 2005-11-25 10:36:07
|
Hi Aparna, > I would like to get the name of the Peer from asterisk , when it > registers. how shouild i go abt implementing this? > i know i shd luk into PeerStatusEvent. but being new to Java, i would > like some sample code to help me with. you are right about the PeerStatusEvent. Your application will have to listen for events that are received from Asterisk, for each event check if it is a PeerStatusEvent and then do something with it. To get started i suggest you to have a look at the tutorial available at http://www.asteriskjava.org/latest/tutorial.html There you will find the HelloEvents class that already does something similar. It listens for all events received within 10 seconds and prints them to the console. As you are only interested in the PeerStatusEvent you will want to change the handleEvent to check for it: public void handleEvent(ManagerEvent event) { if (event instanceof PeerStatusEvent) { String peerName = ((PeerStatusEvent) event).getPeer(); System.out.println("Got a PeerStatusEvent for " + peerName); } } Of course you probably want to do something more sophisticated that just printing out the name :) Hope that helps you get started. =Stefan Aparna Ramakrishnan schrieb: > Hi all, > > > kindly guide. > > thanks n regards > aparna > > Yahoo! Music Unlimited - Access over 1 million songs. Try it free. > <http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/> > |
From: Aparna R. <apa...@ya...> - 2005-11-25 10:02:29
|
Hi all, I'm completely new to Java and need help n guidance in using asterisk-java. I would like to get the name of the Peer from asterisk , when it registers. how shouild i go abt implementing this? i know i shd luk into PeerStatusEvent. but being new to Java, i would like some sample code to help me with. kindly guide. thanks n regards aparna --------------------------------- Yahoo! Music Unlimited - Access over 1 million songs. Try it free. |
From: <kin...@ne...> - 2005-11-17 04:32:35
|
Thanks!! That solved the problem. Best Regards, King |
From: Stefan R. <ste...@gm...> - 2005-11-16 20:22:25
|
Hi, see my response to Brett's mail at http://sourceforge.net/mailarchive/forum.php?thread_id=3D8916340&forum_id= =3D44155 The problem is related to synchronously sending an action from the ManagerReader thread. Try to use send managerConnection.sendAction(new StatusAction(), null); instead and test if that works. =3DStefan |
From: <kin...@ne...> - 2005-11-16 04:55:14
|
Hi, I am trying to send a Status Action whenever the connection to the server is reestablished (For example, if I do a "restart now" in Asterisk I want to send a StatusAction when the connection is reestablished) Below is part of the handleEvent method: public void handleEvent(ManagerEvent event) { if (event instanceof ConnectEvent) { System.out.println("Server connection re-established!!!!!!!"); try { managerConnection.sendAction(new StatusAction()); } catch (IOException e) { } catch (TimeoutException e) { } } } It seems that sending the StatusAction will somehow make the reconnection to the server failed. The output from Asterisk is: == Connect attempt from '192.168.0.10' unable to authenticate This is strange as the ConnectEvent should only be sent if login is successful. If I remove the sendAction, I can see from Asterisk that the reconnection is successful. Do I need to wait some time after receiving a connectEvent and before sending any action? By the way, I am using 0.2 rc2 version of the library and Asterisk 1.2.0 rc2. Thanks in advance. Best Regards, King |
From: Stefan R. <sr...@re...> - 2005-11-15 12:57:18
|
> One thing I noticed that only seems to occur on our linux-based > production server is that I see messages in asterisk every few minutes > saying: > > Connect attempt from '127.0.0.1' unable to authenticate probably a manager connection that tries to connect using incorrect credentials. If you cant find the cause easily just run a sniffer like ngrep or ethereal and look whats going on. (those tools already saved me lots of headaches ;) =Stefan |
From: Stefan R. <sr...@re...> - 2005-11-15 12:55:05
|
Hi Paul, sorry for my late reply. > Thanks for your reply. I think you have a good point about just using > two separate servers. I am actually planning on using multiple servers > as well, but thought it might be useful to also have two instances of > my app running on each server too. Sort of double-load balancing. actually with regard to the Asterisk integration it doesnt matter if you are running two instances on different ports on one machine or two instances on the same port on different machines. I think its better to always use all your resources. Maybe thats based on personal experience with "cold-standby" instances that refuse work right in the second when you need them. > Part > of the complexity is that the app uses both the Manager and AGI, but I > use a database to queue up calls to be placed at specific times. This > makes things a little trickier, as I need a "cluster coordinator" to > ensure that only one process is reading from the database queue at a > time. Once calls are pulled from the DB, I use a JMS queue to > disseminate calls to multiple instances of my app, which then initiate > calls via the Manager interface. Right now, I pass an asterisk variable > along with an Origination action, specifying the hostname of the > calling application, so that messages can be easily sent back to the > same server via AGI (I specify a variable name for the hostname in the > dial plan to get this to work -- this is the same variable passed in > via the Manager, in the Origination action). This I think is where > things get a bit messy, since my design always tries to pass info back > to the same server (i.e. between Manager and AGI). [...] > So my question, is what do you think of this type of design? Is there > a better approach that might still make configuration easier? I don't think this design is not that bad at all. If you define one node of your system to include a JMS consumer, a Manager connection to Asterisk and an AGI-Server that will work quite well. You dont even need a variable for the originate but could directly originate to the associated AGI Server like this: originateAction.setApplication("AGI"); originateAction.setData("agi://" + hostname + ":" + port + "/script.agi?callId=" + callId); The challenge with this kind of setup is to make sure that a node either is fully available or completely down. That is that there are no nodes that accept JMS messages but cant originate calls or that can originate calls but cant answer them via AGI. The big advantage is that it scales indefinitly. > What are > you doing in your dialplan to create the logic to try a different > server if one doesn't respond? I usually set a variable in my AGI scripts that indicates success and verifiy in the dialplan that this variable is set to the expected value. If it is not I know that the AGI didnt run and try the next AGIServer. > I also had an idea to listen to Registration events, in case an > asterisk server wasn't able to successfully register (or lost > connection) with a gateway. That way, in case of a failure, I could > pull the relevant apps out of the cluster, so that they didn't receive > calling commands via JMS (since calls wouldn't be able to be > successfully initiated). A successful Registration event could then > cause an app to rejoin the cluster in order to start responding to call > requests. yep thats probably a task that each node can do for itself and just leave the JMS queue in case of trouble (and maybe rejoin later). you will also benefit from a central coordinator for monitoring. You might want to check that there is a feedback about a call processed in response to a JMS message within a certain timeframe and otherwise exclude the responsible node. > Anyway, I just thought I'd share my design to see what you thought of > our approach, and whether you had any suggestions or caveats. Thanks a lot! I think its very important to share and discuss some general design and deployment ideas as there are really plenty of options regarding Asterisk-Java's usage. > As far as CCXML, there is an open-source Java-based parser out there > already, and from a cursory examination of the code, looks like a > decent start, although I don't think it is complete. I believe it uses > Rhino for javascript integration. Anyway, you can learn more at: > > http://sourceforge.net/projects/ccxml4j > > The java source is only in CVS, and it looks a bit abandoned, but > nevertheless, it's a start. Ok i'll have a look at it later this week. > Thanks again for all your help and feedback. And please let me know if > you think it would be worthwhile to create a CCXML/asterisk-Java > project. I will give you some feedback soon. > I'd definitely be willing to give it a shot, if you thought it > might be useful. And if you need any help with anything else related to > Asterisk-Java, please let me know -- I'd be happy to help out in any > way I can. Thanks, thats great. Another item on my Asterisk-Java todo list is finishing the AsteriskManager.java interface. It should be as easy to use as possible and free the developer from diving into the Actions, Responses and Events. You can already see some of the initial work in the current code, but there is much work left - especially designing a developer-friendly interface ;) =Stefan |
From: Paul F. <pa...@sm...> - 2005-11-10 22:07:20
|
Hi, One thing I noticed that only seems to occur on our linux-based production server is that I see messages in asterisk every few minutes saying: Connect attempt from '127.0.0.1' unable to authenticate I'm not sure what is causing this, so I thought I would ask on the list to see if anyone else had experienced this issue. Everything does seem to be working OK, as my Java app does in fact connect successfully when it first starts up. These messages seem to appear consistently a few minutes after start-up, so I'm guessing that some other thread must be trying to reconnect, but not passing in proper credential info? Or perhaps there are too many Manager connections? Anyway, please let me know if you have experienced similar behavior. I am currently trying to refactor some of my code that is based on the Manager interface to see if this is the result of some coding issue. Thanks, Paul Paul T. Fisher SmartPants Media, Inc. http://www.smartpants.com |
From: Paul F. <pa...@sm...> - 2005-11-10 21:38:40
|
Hi Stefan, Thanks for your reply. I think you have a good point about just using two separate servers. I am actually planning on using multiple servers as well, but thought it might be useful to also have two instances of my app running on each server too. Sort of double-load balancing. Part of the complexity is that the app uses both the Manager and AGI, but I use a database to queue up calls to be placed at specific times. This makes things a little trickier, as I need a "cluster coordinator" to ensure that only one process is reading from the database queue at a time. Once calls are pulled from the DB, I use a JMS queue to disseminate calls to multiple instances of my app, which then initiate calls via the Manager interface. Right now, I pass an asterisk variable along with an Origination action, specifying the hostname of the calling application, so that messages can be easily sent back to the same server via AGI (I specify a variable name for the hostname in the dial plan to get this to work -- this is the same variable passed in via the Manager, in the Origination action). This I think is where things get a bit messy, since my design always tries to pass info back to the same server (i.e. between Manager and AGI). I suppose I could use a different set- up, but the goal is that such a system design makes it easy to add new nodes to the cluster -- since new apps can simply join a JMS queue, and when they receive a command to place a call, they can just specify the originating IP address via Manager variables. Again, the benefit is that I don't need to do any additional configuration to add new nodes to the system. The drawback is that since asterisk will always try to just reply via AGI to the same server that originated the request via the Manager, it becomes important to have multiple "calling nodes" (i.e. my asterisk-java app using the Manager/AGI interfaces)on the same server, in case one of them goes down. So my question, is what do you think of this type of design? Is there a better approach that might still make configuration easier? What are you doing in your dialplan to create the logic to try a different server if one doesn't respond? I also had an idea to listen to Registration events, in case an asterisk server wasn't able to successfully register (or lost connection) with a gateway. That way, in case of a failure, I could pull the relevant apps out of the cluster, so that they didn't receive calling commands via JMS (since calls wouldn't be able to be successfully initiated). A successful Registration event could then cause an app to rejoin the cluster in order to start responding to call requests. Anyway, I just thought I'd share my design to see what you thought of our approach, and whether you had any suggestions or caveats. As far as CCXML, there is an open-source Java-based parser out there already, and from a cursory examination of the code, looks like a decent start, although I don't think it is complete. I believe it uses Rhino for javascript integration. Anyway, you can learn more at: http://sourceforge.net/projects/ccxml4j The java source is only in CVS, and it looks a bit abandoned, but nevertheless, it's a start. Thanks again for all your help and feedback. And please let me know if you think it would be worthwhile to create a CCXML/asterisk-Java project. I'd definitely be willing to give it a shot, if you thought it might be useful. And if you need any help with anything else related to Asterisk-Java, please let me know -- I'd be happy to help out in any way I can. Best Regards, Paul Paul T. Fisher SmartPants Media, Inc. http://www.smartpants.com On Nov 9, 2005, at 11:04 PM, asterisk-java-users- re...@li... wrote: > Send Asterisk-java-users mailing list submissions to > ast...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > or, via email, send a message with subject or body 'help' to > ast...@li... > > You can reach the person managing the list at > ast...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Asterisk-java-users digest..." > > > Today's Topics: > > 1. DefaultAGIServer bind exception (Paul Fisher) > > --__--__-- > > Message: 1 > From: Paul Fisher <pa...@sm...> > Date: Wed, 9 Nov 2005 18:41:17 -0500 > To: ast...@li... > Subject: [Asterisk-java-users] DefaultAGIServer bind exception > Reply-To: ast...@li... > > Hi, > > I'm currently using Asterisk-Java in a project where I would like to > have a cluster of apps, primarily as a stand-by in case one of the > apps goes down. Everything is great, except if I have two instances > of the DefaultAGIServer running, the second instance to start up will > obviously fail with a BindException. This isn't much of a problem, > except I can imagine a scenario where two servers are running, the > first goes down, but even though the second is still running, the > AGIServer thread won't be working since it failed on start-up. The > problem I am running into is that there is no easy way to find out if > the AGIServer thread failed or not. The BindException is swallowed > inside DefaultAGIServer.java, and there is no property that gets set > that might allow me to query if things are running or nut (so that I > can easily restart the AGIServer thread if necessary). > > I have actually updated the source to include an isRunning boolean > property, as well as rethrowing the IOException that gets caught in > the case of a failed serverSocket instantiation. Is this OK to do? If > so, should I submit a patch or something, as I imagine it could be > useful to at least query the status of the DefaultAGIServer thread. > Of course I could just subclass DefaultAGIServer to get this to work, > but I figured I should ask if there might be any problems or a better > way of doing this. > > Great library by the way. I'm more than happy to help out if you need > any assistance. I had thought of integrating the CCXML somehow to > more easily get at call control, but wasn't sure how to go about > getting started on that. . . any ideas? > > Paul > > Paul T. Fisher. > SmartPants Media, Inc. > pa...@sm... > 1-(877)-849-4244 (Toll Free) > 1-(443)-451-5549 > > > > On Nov 8, 2005, at 11:12 PM, asterisk-java-users- > re...@li... wrote: > >> Send Asterisk-java-users mailing list submissions to >> ast...@li... >> >> To subscribe or unsubscribe via the World Wide Web, visit >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >> or, via email, send a message with subject or body 'help' to >> ast...@li... >> >> You can reach the person managing the list at >> ast...@li... >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of Asterisk-java-users digest..." >> >> >> Today's Topics: >> >> 1. Timeout when hanging up (Brett Sutton) >> 2. Re: Timeout when hanging up (Stefan Reuter) >> 3. Re: Set Global Variable via Manager API (Stefan Reuter) >> 4. Re: Timeout when hanging up (Brett Sutton) >> 5. Re: Set Global Variable via Manager API (Gerwin Bruner) >> 6. Re: Timeout when hanging up (Stefan Reuter) >> 7. Re: Timeout when hanging up (Brett Sutton) >> >> -- __--__-- >> >> Message: 1 >> Date: Tue, 08 Nov 2005 20:15:15 +1100 >> From: Brett Sutton <bs...@id...> >> To: ast...@li... >> Subject: [Asterisk-java-users] Timeout when hanging up >> Reply-To: ast...@li... >> >> I'm trying something which is probably a little unusual. >> Basically I want to check if a number is inservice or out of service. >> I do this by dialing the number and if it rings I instantly drop the >> connection by hanging up. >> >> The code basically works fine however the hangup action is throwing a >> timeout even though the line is successfully hung up. >> Even if I set the time to 30 seconds a timeout still occurs, where as >> the sip phone I'm dialing hangs up immediately. >> >> Interestingly as soon as the hangup times out I get a HangupEvent. >> >> So I thought it might be worth posting the code here for inspection >> and >> comment. >> >> /* >> * Created on 8/11/2005 >> * >> * To change the template for this generated file go to >> * Window - Preferences - Java - Code Generation - Code and Comments >> */ >> package Carma.voip.cleaner; >> >> import java.io.IOException; >> >> import net.sf.asterisk.manager.AuthenticationFailedException; >> import net.sf.asterisk.manager.ManagerConnection; >> import net.sf.asterisk.manager.ManagerConnectionFactory; >> import net.sf.asterisk.manager.ManagerEventHandler; >> import net.sf.asterisk.manager.ManagerResponseHandler; >> import net.sf.asterisk.manager.TimeoutException; >> import net.sf.asterisk.manager.action.HangupAction; >> import net.sf.asterisk.manager.action.OriginateAction; >> import net.sf.asterisk.manager.action.StatusAction; >> import net.sf.asterisk.manager.event.ManagerEvent; >> import net.sf.asterisk.manager.event.NewChannelEvent; >> import net.sf.asterisk.manager.response.ManagerResponse; >> >> public class Manager implements ManagerEventHandler, >> ManagerResponseHandler >> { >> >> private ManagerConnection managerConnection; >> >> public Manager() throws IOException >> { >> ManagerConnectionFactory factory = new >> ManagerConnectionFactory(); >> >> this.managerConnection = factory.getManagerConnection >> ("10.0.5.55", >> "username", "password"); >> } >> >> public void run() throws IOException, >> AuthenticationFailedException, >> TimeoutException >> { >> OriginateAction originateAction; >> ManagerResponse originateResponse; >> >> originateAction = new OriginateAction(); >> originateAction.setChannel("SIP/202"); >> originateAction.setContext("default"); >> originateAction.setExten("202"); >> originateAction.setPriority(new Integer(1)); >> originateAction.setTimeout(new Integer(30000)); >> originateAction.setAsync(new Boolean(true)); >> >> // register for events >> managerConnection.addEventHandler(this); >> >> // connect to Asterisk and log in >> managerConnection.login(); >> >> // request channel state >> managerConnection.sendAction(new StatusAction()); >> >> managerConnection.sendAction(originateAction, this); >> >> try >> { >> Thread.sleep(10000); >> } >> catch (InterruptedException e) >> { >> // TODO Auto-generated catch block >> e.printStackTrace(); >> } >> >> // and finally log off and disconnect >> managerConnection.logoff(); >> } >> >> public void handleEvent(ManagerEvent event) >> { >> if (event instanceof NewChannelEvent) >> { >> NewChannelEvent cevent = (NewChannelEvent) event; >> System.out.println(cevent.getState()); >> if (cevent.getState().compareToIgnoreCase("Ringing") >> == 0) >> { >> HangupAction hangup = new HangupAction(); >> hangup.setChannel(cevent.getChannel()); >> try >> { >> // The problem is here, I've also tried explicit >> timeouts of upto 30seconds and an timeout exception is still thrown. >> managerConnection.sendAction(hangup); >> } >> catch (IllegalArgumentException e) >> { >> // TODO Auto-generated catch block >> e.printStackTrace(); >> } >> catch (IllegalStateException e) >> { >> // TODO Auto-generated catch block >> e.printStackTrace(); >> } >> catch (IOException e) >> { >> // TODO Auto-generated catch block >> e.printStackTrace(); >> } >> catch (TimeoutException e) >> { >> // We ignore the timeout as for some reason >> hangup >> always times out. >> } >> } >> >> } >> >> // just print received events >> System.out.println("Event: " + event); >> } >> >> public void handleResponse(ManagerResponse response) >> { >> System.out.println("Response: " + response); >> } >> >> public static void main(String[] args) throws Exception >> { >> Manager helloManager; >> >> helloManager = new Manager(); >> helloManager.run(); >> } >> >> } >> >> >> >> -- __--__-- >> >> Message: 2 >> Date: Tue, 08 Nov 2005 12:24:02 +0100 >> From: Stefan Reuter <sr...@re...> >> To: ast...@li... >> Subject: Re: [Asterisk-java-users] Timeout when hanging up >> Reply-To: ast...@li... >> >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Hi Brett, >> >> your code looks ok. >> If you receive a TimeoutException this indicates that Astersik does >> not >> return a Response to your Action. >> I just tried your code with Asterisk CVS-HEAD and it I dont get any >> timeout. What version of Asterisk and Asterisk-Java do you use? >> >> It would help if you could send me a trace of the conversation >> between >> Asterisk and your application. >> I usually generate them using ngrep on my Asterisk server >> (ngrep -s 4000 port 5038 works well). >> Then we can quickly see the cause of this problem. >> >> =Stefan >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.2 (MingW32) >> Comment: GnuPT 2.7.2 >> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org >> >> iD8DBQFDcIrSTUZ7XZofpgURAtaEAKCcVYMBzdjYOjJmxgvGW02B0JRi9QCgv+HM >> OI5pyRbOG6hc0MoeqpyXLPk= >> =cwpS >> -----END PGP SIGNATURE----- >> >> >> -- __--__-- >> >> Message: 3 >> Date: Tue, 08 Nov 2005 12:41:07 +0100 >> From: Stefan Reuter <sr...@re...> >> To: ast...@li... >> Subject: Re: [Asterisk-java-users] Set Global Variable via Manager >> API >> Reply-To: ast...@li... >> >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Stefan Reuter schrieb: >>> I just posted >>> http://bugs.digium.com/view.php?id=5571 >>> to fix the SetVar. >> >> That patch has been accepted by digium. >> So when using latest CVS-HEAD of Asterisk the channel property of the >> SetVarAction is optional. To set a global variable only set the >> variable >> and value properties of SetVarAction and leave channel empty. >> I just updated Asterisk-Java's javadoc and added a convenience >> constructor to SetVarAction that takes a variable and value. >> >> =Stefan >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.2 (MingW32) >> Comment: GnuPT 2.7.2 >> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org >> >> iD8DBQFDcI7TTUZ7XZofpgURAq4LAKDAiWtVNpahbdpELxeUYll6Q+zv7QCgh9aF >> am3AIWHrbzVVTWbGHuv8gng= >> =1tGM >> -----END PGP SIGNATURE----- >> >> >> -- __--__-- >> >> Message: 4 >> Date: Tue, 08 Nov 2005 22:45:20 +1100 >> From: Brett Sutton <bs...@no...> >> To: ast...@li... >> Subject: Re: [Asterisk-java-users] Timeout when hanging up >> Reply-To: ast...@li... >> >> Thanks for the prompt reply. >> >> I'm using asterisk-java 0.2 rc2 and asterisk @ home 1.0.9. >> >> Here is the trace: >> >> login as: root >> root@10.0.5.55's password: >> Last login: Tue Nov 8 09:32:06 2005 from >> crystalreportsxi.cwmedia.com.au >> >> Welcome to Asterisk@Home >> ------------------------------------------------- >> >> For access to the Asterisk@Home web GUI use this URL >> http://10.0.5.55 >> >> For help on Asterisk@Home commands you can use from this >> command shell type help-aah. >> >> [root@asterisk1 root]# ngrep -s 4000 port 5038 >> interface: eth0 (10.0.0.0/255.255.0.0) >> filter: ip and ( port 5038 ) >> #### >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Asterisk Call Manager/1.0.. >> # >> T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] >> action: Challenge..actionid: 16939420_0#..authtype: MD5.... >> ## >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Response: Success..ActionID: 16939420_0#..Challenge: 680897534.... >> # >> T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] >> key: 99fa3b5002176ef1355028ca360e5c0d..action: Login..actionid: >> 16939420_1# >> ..authtype: MD5..username: admin.... >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Response: Success.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> ActionID: 16939420_1#.. >> ## >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Message: Authentication accepted.... >> # >> T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] >> command: show version files..action: Command..actionid: >> 16939420_2#.... >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Response: Follows.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> ActionID: 16939420_2#.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Usage: show version. Shows Asterisk version information.. >> ## >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> --END COMMAND--.... >> # >> T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] >> action: Status..actionid: 16939420_3#.... >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Response: Success.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> ActionID: 16939420_3#.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Message: Channel status will follow.... >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Event: Status..Channel: SIP/202-d2da..CallerID: <unknown>..Account: >> ..State >> : Up..Context: macro-vm..Extension: s-BUSY..Priority: 1..Seconds: >> 3483..Uni >> queid: 1131446599.1005..ActionID: 16939420_3#.... >> ## >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Event: Status..Channel: SIP/202-dda4..CallerID: "brett" >> <202>..Account: ..S >> tate: Up..Context: macro-vm..Extension: s-CHANUNAVAIL..Priority: >> 1..Seconds >> : 5195..Uniqueid: 1131444894.829..ActionID: 16939420_3#....Event: >> Status..C >> hannel: SIP/202-fb58..CallerID: <unknown>..Account: ..State: >> Up..Context: m >> acro-vm..Extension: s-BUSY..Priority: 1..Seconds: 17593..Uniqueid: >> 11314324 >> 90.18..ActionID: 16939420_3#....Event: StatusComplete..ActionID: >> 16939420_3 >> #.... >> ## >> T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] >> action: Originate..timeout: 30000..actionid: 16939420_4#..exten: >> 202..async >> : true..context: default..priority: 1..channel: SIP/202.... >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Event: Newchannel.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Channel: SIP/202-91c6..State: Down..CallerID: <unknown>..Uniqueid: >> 11314500 >> 89.1011.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> .. >> ## >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Response: Success.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> ActionID: 16939420_4#.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Message: Originate successfully queued.... >> ## >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Event: Newchannel.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Channel: SIP/202-91c6..State: Ringing..CallerID: >> <unknown>..Uniqueid: >> 11314 >> 50089.1011.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> .. >> ## >> T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] >> action: Hangup..actionid: 16939420_5#..channel: SIP/202-91c6.... >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Response: Success.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> ActionID: 16939420_5#.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Message: Channel Hungup.... >> ## >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Event: Hangup.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Channel: SIP/202-91c6..Uniqueid: 1131450089.1011..Cause: 16.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> .. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Event: OriginateFailure.. >> ## >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> ActionID: 16939420_4#..Channel: SIP/202..Context: default..Exten: >> 202.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> .. >> ### >> T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] >> action: Logoff..actionid: 16939420_6#.... >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Response: Goodbye.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> ActionID: 16939420_6#.. >> # >> T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] >> Message: Thanks for all the fish..... >> #### >> >> >> Stefan Reuter wrote: >> >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> Hi Brett, >>> >>> your code looks ok. >>> If you receive a TimeoutException this indicates that Astersik >>> does not >>> return a Response to your Action. >>> I just tried your code with Asterisk CVS-HEAD and it I dont get any >>> timeout. What version of Asterisk and Asterisk-Java do you use? >>> >>> It would help if you could send me a trace of the conversation >>> between >>> Asterisk and your application. >>> I usually generate them using ngrep on my Asterisk server >>> (ngrep -s 4000 port 5038 works well). >>> Then we can quickly see the cause of this problem. >>> >>> =Stefan >>> -----BEGIN PGP SIGNATURE----- >>> Version: GnuPG v1.4.2 (MingW32) >>> Comment: GnuPT 2.7.2 >>> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org >>> >>> iD8DBQFDcIrSTUZ7XZofpgURAtaEAKCcVYMBzdjYOjJmxgvGW02B0JRi9QCgv+HM >>> OI5pyRbOG6hc0MoeqpyXLPk= >>> =cwpS >>> -----END PGP SIGNATURE----- >>> >>> >>> ------------------------------------------------------- >>> SF.Net email is sponsored by: >>> Tame your development challenges with Apache's Geronimo App >>> Server. Download >>> it for free - -and be entered to win a 42" plasma tv or your very >>> own >>> Sony(tm)PSP. Click here to play: http://sourceforge.net/ >>> geronimo.php >>> _______________________________________________ >>> Asterisk-java-users mailing list >>> Ast...@li... >>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >>> >>> >> >> >> >> -- __--__-- >> >> Message: 5 >> From: Gerwin Bruner <ger...@gm...> >> Subject: Re: [Asterisk-java-users] Set Global Variable via Manager >> API >> Date: Tue, 8 Nov 2005 12:47:39 +0100 >> To: ast...@li... >> Reply-To: ast...@li... >> >> Great, >> >> thanks very much. >> >> Gerwin >> >> On Nov 8, 2005, at 12:41 PM, Stefan Reuter wrote: >> >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> Stefan Reuter schrieb: >>>> I just posted >>>> http://bugs.digium.com/view.php?id=5571 >>>> to fix the SetVar. >>> >>> That patch has been accepted by digium. >>> So when using latest CVS-HEAD of Asterisk the channel property of >>> the >>> SetVarAction is optional. To set a global variable only set the >>> variable >>> and value properties of SetVarAction and leave channel empty. >>> I just updated Asterisk-Java's javadoc and added a convenience >>> constructor to SetVarAction that takes a variable and value. >>> >>> =Stefan >>> -----BEGIN PGP SIGNATURE----- >>> Version: GnuPG v1.4.2 (MingW32) >>> Comment: GnuPT 2.7.2 >>> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org >>> >>> iD8DBQFDcI7TTUZ7XZofpgURAq4LAKDAiWtVNpahbdpELxeUYll6Q+zv7QCgh9aF >>> am3AIWHrbzVVTWbGHuv8gng= >>> =1tGM >>> -----END PGP SIGNATURE----- >>> >>> >>> ------------------------------------------------------- >>> SF.Net email is sponsored by: >>> Tame your development challenges with Apache's Geronimo App Server. >>> Download >>> it for free - -and be entered to win a 42" plasma tv or your very >>> own >>> Sony(tm)PSP. Click here to play: http://sourceforge.net/ >>> geronimo.php >>> _______________________________________________ >>> Asterisk-java-users mailing list >>> Ast...@li... >>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >> >> >> >> -- __--__-- >> >> Message: 6 >> Date: Tue, 08 Nov 2005 14:29:21 +0100 >> From: Stefan Reuter <sr...@re...> >> To: ast...@li... >> Subject: Re: [Asterisk-java-users] Timeout when hanging up >> Reply-To: ast...@li... >> >> This is an OpenPGP/MIME signed message (RFC 2440 and 3156) >> --------------enig5EA84A11294D8A07638B4E7E >> Content-Type: text/plain; charset=ISO-8859-1 >> Content-Transfer-Encoding: 7bit >> >> Hi Brett, >> >> thank you for the trace. >> Everything behaves correctly. I just had my brain switched off ;) >> >> At first some background information about how Asterisk-Java works: >> Generally when using the ManagerConnection there are two threads >> involved. Your "normal" application thread ("Main") and an addtional >> thread for the ManagerReader. >> The ManagerReader thread reads repsonses and events from Asterisk and >> dispatches them to the event and repsonse handlers. >> >> What happened in your case is the following: >> >> You register an event handler that is called on a NewChannelEvent. >> This >> event hanler is called from the ManagerReader thread. Now you send a >> HangupAction to Asterisk and wait for the response. The response can >> only be read and dispatched by the ManagerReader thread but that >> ManagerReader thread is already blocked waiting for the response... a >> deadlock. >> >> So what to do in such a case? >> Generally don't do anything that blocks the ManagerReader thread in >> event handlers. So you have two options: >> a) send the HangupAction in a non-blocking way: >> managerConnection.sendAction(hangup, null); >> b) create an additional thread that does the hangup and only >> asynchronously inform that thread in your handleEvent() method >> >> I think a) will be sufficient in this case. (but you loose the >> resposne >> to the hangup action) >> >> =Stefan >> >> >> >> --------------enig5EA84A11294D8A07638B4E7E >> Content-Type: application/pgp-signature; name="signature.asc" >> Content-Description: OpenPGP digital signature >> Content-Disposition: attachment; filename="signature.asc" >> >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.2 (MingW32) >> Comment: GnuPT 2.7.2 >> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org >> >> iD8DBQFDcKg4TUZ7XZofpgURAqOmAKCISuhst/Gy9UQaIA+IVMA6lHDU4gCfV1N/ >> xqm9JZZ+k5wAQ0hBUqHPn8w= >> =dJKr >> -----END PGP SIGNATURE----- >> >> --------------enig5EA84A11294D8A07638B4E7E-- >> >> >> -- __--__-- >> >> Message: 7 >> Date: Wed, 09 Nov 2005 08:52:51 +1100 >> From: Brett Sutton <bs...@no...> >> To: ast...@li... >> Subject: Re: [Asterisk-java-users] Timeout when hanging up >> Reply-To: ast...@li... >> >> Thanks for your help. >> I don't think you were the only one with you brain switched off, now >> that you point it out the problem is obvious. >> >> I'm not terribly interested in the result of the hangup so I would >> agree >> option 'a' should work nicely. >> >> Once again many thanks for you help. >> Brett. >> >> >> Stefan Reuter wrote: >> >>> Hi Brett, >>> >>> thank you for the trace. >>> Everything behaves correctly. I just had my brain switched off ;) >>> >>> At first some background information about how Asterisk-Java works: >>> Generally when using the ManagerConnection there are two threads >>> involved. Your "normal" application thread ("Main") and an addtional >>> thread for the ManagerReader. >>> The ManagerReader thread reads repsonses and events from Asterisk >>> and >>> dispatches them to the event and repsonse handlers. >>> >>> What happened in your case is the following: >>> >>> You register an event handler that is called on a NewChannelEvent. >>> This >>> event hanler is called from the ManagerReader thread. Now you send a >>> HangupAction to Asterisk and wait for the response. The response can >>> only be read and dispatched by the ManagerReader thread but that >>> ManagerReader thread is already blocked waiting for the >>> response... a >>> deadlock. >>> >>> So what to do in such a case? >>> Generally don't do anything that blocks the ManagerReader thread in >>> event handlers. So you have two options: >>> a) send the HangupAction in a non-blocking way: >>> managerConnection.sendAction(hangup, null); >>> b) create an additional thread that does the hangup and only >>> asynchronously inform that thread in your handleEvent() method >>> >>> I think a) will be sufficient in this case. (but you loose the >>> resposne >>> to the hangup action) >>> >>> =Stefan >>> >>> >>> >>> >> >> >> >> >> -- __--__-- >> >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >> >> >> End of Asterisk-java-users Digest > > > > > --__--__-- > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > End of Asterisk-java-users Digest |
From: Stefan R. <sr...@re...> - 2005-11-10 11:12:35
|
Hi Paul, first of all you are right that just swallowing the bind exception is not a good idea. Especially as the AGIServer interface explicitly denotes that an IOException may be thrown on startup. So DefaultAGIServer is not well implemented. I fixed this so that you receive an IOException in case of a bind failure. Please have a look at http://maven.reucon.org/maven/org.asteriskjava/distributions/asterisk-java-0.2-SNAPSHOT.zip and test it. I hope that also removes the need for your isRunning() method. Regarding your clustering ideas I do not yet fully understand what you are trying to achieve, i.e. what kind of outages you think of. If I need high availability of an AGI based application I usually run it on two or more seperate boxes and add some logic to the dialplan to execute the AGI on the first server and if that fails to use the second one. So there are two AGI servers up and running all the time and they are fully functional. > Great library by the way. I'm more than happy to help out if you need > any assistance. I had thought of integrating the CCXML somehow to more > easily get at call control, but wasn't sure how to go about getting > started on that. . . any ideas? Yes supporting something like CCXML on top of the library would be cool. Do you know of any opensource work that we could use (like a CCXML parser or whatever)? =Stefan |
From: Paul F. <pa...@sm...> - 2005-11-09 23:38:35
|
Hi, I'm currently using Asterisk-Java in a project where I would like to have a cluster of apps, primarily as a stand-by in case one of the apps goes down. Everything is great, except if I have two instances of the DefaultAGIServer running, the second instance to start up will obviously fail with a BindException. This isn't much of a problem, except I can imagine a scenario where two servers are running, the first goes down, but even though the second is still running, the AGIServer thread won't be working since it failed on start-up. The problem I am running into is that there is no easy way to find out if the AGIServer thread failed or not. The BindException is swallowed inside DefaultAGIServer.java, and there is no property that gets set that might allow me to query if things are running or nut (so that I can easily restart the AGIServer thread if necessary). I have actually updated the source to include an isRunning boolean property, as well as rethrowing the IOException that gets caught in the case of a failed serverSocket instantiation. Is this OK to do? If so, should I submit a patch or something, as I imagine it could be useful to at least query the status of the DefaultAGIServer thread. Of course I could just subclass DefaultAGIServer to get this to work, but I figured I should ask if there might be any problems or a better way of doing this. Great library by the way. I'm more than happy to help out if you need any assistance. I had thought of integrating the CCXML somehow to more easily get at call control, but wasn't sure how to go about getting started on that. . . any ideas? Paul Paul T. Fisher. SmartPants Media, Inc. pa...@sm... 1-(877)-849-4244 (Toll Free) 1-(443)-451-5549 On Nov 8, 2005, at 11:12 PM, asterisk-java-users- re...@li... wrote: > Send Asterisk-java-users mailing list submissions to > ast...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > or, via email, send a message with subject or body 'help' to > ast...@li... > > You can reach the person managing the list at > ast...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Asterisk-java-users digest..." > > > Today's Topics: > > 1. Timeout when hanging up (Brett Sutton) > 2. Re: Timeout when hanging up (Stefan Reuter) > 3. Re: Set Global Variable via Manager API (Stefan Reuter) > 4. Re: Timeout when hanging up (Brett Sutton) > 5. Re: Set Global Variable via Manager API (Gerwin Bruner) > 6. Re: Timeout when hanging up (Stefan Reuter) > 7. Re: Timeout when hanging up (Brett Sutton) > > --__--__-- > > Message: 1 > Date: Tue, 08 Nov 2005 20:15:15 +1100 > From: Brett Sutton <bs...@id...> > To: ast...@li... > Subject: [Asterisk-java-users] Timeout when hanging up > Reply-To: ast...@li... > > I'm trying something which is probably a little unusual. > Basically I want to check if a number is inservice or out of service. > I do this by dialing the number and if it rings I instantly drop the > connection by hanging up. > > The code basically works fine however the hangup action is throwing a > timeout even though the line is successfully hung up. > Even if I set the time to 30 seconds a timeout still occurs, where as > the sip phone I'm dialing hangs up immediately. > > Interestingly as soon as the hangup times out I get a HangupEvent. > > So I thought it might be worth posting the code here for inspection > and > comment. > > /* > * Created on 8/11/2005 > * > * To change the template for this generated file go to > * Window - Preferences - Java - Code Generation - Code and Comments > */ > package Carma.voip.cleaner; > > import java.io.IOException; > > import net.sf.asterisk.manager.AuthenticationFailedException; > import net.sf.asterisk.manager.ManagerConnection; > import net.sf.asterisk.manager.ManagerConnectionFactory; > import net.sf.asterisk.manager.ManagerEventHandler; > import net.sf.asterisk.manager.ManagerResponseHandler; > import net.sf.asterisk.manager.TimeoutException; > import net.sf.asterisk.manager.action.HangupAction; > import net.sf.asterisk.manager.action.OriginateAction; > import net.sf.asterisk.manager.action.StatusAction; > import net.sf.asterisk.manager.event.ManagerEvent; > import net.sf.asterisk.manager.event.NewChannelEvent; > import net.sf.asterisk.manager.response.ManagerResponse; > > public class Manager implements ManagerEventHandler, > ManagerResponseHandler > { > > private ManagerConnection managerConnection; > > public Manager() throws IOException > { > ManagerConnectionFactory factory = new > ManagerConnectionFactory(); > > this.managerConnection = factory.getManagerConnection > ("10.0.5.55", > "username", "password"); > } > > public void run() throws IOException, > AuthenticationFailedException, > TimeoutException > { > OriginateAction originateAction; > ManagerResponse originateResponse; > > originateAction = new OriginateAction(); > originateAction.setChannel("SIP/202"); > originateAction.setContext("default"); > originateAction.setExten("202"); > originateAction.setPriority(new Integer(1)); > originateAction.setTimeout(new Integer(30000)); > originateAction.setAsync(new Boolean(true)); > > // register for events > managerConnection.addEventHandler(this); > > // connect to Asterisk and log in > managerConnection.login(); > > // request channel state > managerConnection.sendAction(new StatusAction()); > > managerConnection.sendAction(originateAction, this); > > try > { > Thread.sleep(10000); > } > catch (InterruptedException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > // and finally log off and disconnect > managerConnection.logoff(); > } > > public void handleEvent(ManagerEvent event) > { > if (event instanceof NewChannelEvent) > { > NewChannelEvent cevent = (NewChannelEvent) event; > System.out.println(cevent.getState()); > if (cevent.getState().compareToIgnoreCase("Ringing") == 0) > { > HangupAction hangup = new HangupAction(); > hangup.setChannel(cevent.getChannel()); > try > { > // The problem is here, I've also tried explicit > timeouts of upto 30seconds and an timeout exception is still thrown. > managerConnection.sendAction(hangup); > } > catch (IllegalArgumentException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > catch (IllegalStateException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > catch (IOException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > catch (TimeoutException e) > { > // We ignore the timeout as for some reason > hangup > always times out. > } > } > > } > > // just print received events > System.out.println("Event: " + event); > } > > public void handleResponse(ManagerResponse response) > { > System.out.println("Response: " + response); > } > > public static void main(String[] args) throws Exception > { > Manager helloManager; > > helloManager = new Manager(); > helloManager.run(); > } > > } > > > > --__--__-- > > Message: 2 > Date: Tue, 08 Nov 2005 12:24:02 +0100 > From: Stefan Reuter <sr...@re...> > To: ast...@li... > Subject: Re: [Asterisk-java-users] Timeout when hanging up > Reply-To: ast...@li... > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi Brett, > > your code looks ok. > If you receive a TimeoutException this indicates that Astersik does > not > return a Response to your Action. > I just tried your code with Asterisk CVS-HEAD and it I dont get any > timeout. What version of Asterisk and Asterisk-Java do you use? > > It would help if you could send me a trace of the conversation between > Asterisk and your application. > I usually generate them using ngrep on my Asterisk server > (ngrep -s 4000 port 5038 works well). > Then we can quickly see the cause of this problem. > > =Stefan > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2 (MingW32) > Comment: GnuPT 2.7.2 > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFDcIrSTUZ7XZofpgURAtaEAKCcVYMBzdjYOjJmxgvGW02B0JRi9QCgv+HM > OI5pyRbOG6hc0MoeqpyXLPk= > =cwpS > -----END PGP SIGNATURE----- > > > --__--__-- > > Message: 3 > Date: Tue, 08 Nov 2005 12:41:07 +0100 > From: Stefan Reuter <sr...@re...> > To: ast...@li... > Subject: Re: [Asterisk-java-users] Set Global Variable via Manager API > Reply-To: ast...@li... > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Stefan Reuter schrieb: >> I just posted >> http://bugs.digium.com/view.php?id=5571 >> to fix the SetVar. > > That patch has been accepted by digium. > So when using latest CVS-HEAD of Asterisk the channel property of the > SetVarAction is optional. To set a global variable only set the > variable > and value properties of SetVarAction and leave channel empty. > I just updated Asterisk-Java's javadoc and added a convenience > constructor to SetVarAction that takes a variable and value. > > =Stefan > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2 (MingW32) > Comment: GnuPT 2.7.2 > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFDcI7TTUZ7XZofpgURAq4LAKDAiWtVNpahbdpELxeUYll6Q+zv7QCgh9aF > am3AIWHrbzVVTWbGHuv8gng= > =1tGM > -----END PGP SIGNATURE----- > > > --__--__-- > > Message: 4 > Date: Tue, 08 Nov 2005 22:45:20 +1100 > From: Brett Sutton <bs...@no...> > To: ast...@li... > Subject: Re: [Asterisk-java-users] Timeout when hanging up > Reply-To: ast...@li... > > Thanks for the prompt reply. > > I'm using asterisk-java 0.2 rc2 and asterisk @ home 1.0.9. > > Here is the trace: > > login as: root > root@10.0.5.55's password: > Last login: Tue Nov 8 09:32:06 2005 from > crystalreportsxi.cwmedia.com.au > > Welcome to Asterisk@Home > ------------------------------------------------- > > For access to the Asterisk@Home web GUI use this URL > http://10.0.5.55 > > For help on Asterisk@Home commands you can use from this > command shell type help-aah. > > [root@asterisk1 root]# ngrep -s 4000 port 5038 > interface: eth0 (10.0.0.0/255.255.0.0) > filter: ip and ( port 5038 ) > #### > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Asterisk Call Manager/1.0.. > # > T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] > action: Challenge..actionid: 16939420_0#..authtype: MD5.... > ## > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Response: Success..ActionID: 16939420_0#..Challenge: 680897534.... > # > T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] > key: 99fa3b5002176ef1355028ca360e5c0d..action: Login..actionid: > 16939420_1# > ..authtype: MD5..username: admin.... > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Response: Success.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > ActionID: 16939420_1#.. > ## > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Message: Authentication accepted.... > # > T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] > command: show version files..action: Command..actionid: > 16939420_2#.... > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Response: Follows.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > ActionID: 16939420_2#.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Usage: show version. Shows Asterisk version information.. > ## > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > --END COMMAND--.... > # > T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] > action: Status..actionid: 16939420_3#.... > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Response: Success.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > ActionID: 16939420_3#.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Message: Channel status will follow.... > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Event: Status..Channel: SIP/202-d2da..CallerID: <unknown>..Account: > ..State > : Up..Context: macro-vm..Extension: s-BUSY..Priority: 1..Seconds: > 3483..Uni > queid: 1131446599.1005..ActionID: 16939420_3#.... > ## > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Event: Status..Channel: SIP/202-dda4..CallerID: "brett" > <202>..Account: ..S > tate: Up..Context: macro-vm..Extension: s-CHANUNAVAIL..Priority: > 1..Seconds > : 5195..Uniqueid: 1131444894.829..ActionID: 16939420_3#....Event: > Status..C > hannel: SIP/202-fb58..CallerID: <unknown>..Account: ..State: > Up..Context: m > acro-vm..Extension: s-BUSY..Priority: 1..Seconds: 17593..Uniqueid: > 11314324 > 90.18..ActionID: 16939420_3#....Event: StatusComplete..ActionID: > 16939420_3 > #.... > ## > T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] > action: Originate..timeout: 30000..actionid: 16939420_4#..exten: > 202..async > : true..context: default..priority: 1..channel: SIP/202.... > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Event: Newchannel.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Channel: SIP/202-91c6..State: Down..CallerID: <unknown>..Uniqueid: > 11314500 > 89.1011.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > .. > ## > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Response: Success.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > ActionID: 16939420_4#.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Message: Originate successfully queued.... > ## > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Event: Newchannel.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Channel: SIP/202-91c6..State: Ringing..CallerID: > <unknown>..Uniqueid: > 11314 > 50089.1011.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > .. > ## > T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] > action: Hangup..actionid: 16939420_5#..channel: SIP/202-91c6.... > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Response: Success.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > ActionID: 16939420_5#.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Message: Channel Hungup.... > ## > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Event: Hangup.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Channel: SIP/202-91c6..Uniqueid: 1131450089.1011..Cause: 16.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > .. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Event: OriginateFailure.. > ## > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > ActionID: 16939420_4#..Channel: SIP/202..Context: default..Exten: > 202.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > .. > ### > T 10.0.0.205:5164 -> 10.0.5.55:5038 [AP] > action: Logoff..actionid: 16939420_6#.... > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Response: Goodbye.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > ActionID: 16939420_6#.. > # > T 10.0.5.55:5038 -> 10.0.0.205:5164 [AP] > Message: Thanks for all the fish..... > #### > > > Stefan Reuter wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Hi Brett, >> >> your code looks ok. >> If you receive a TimeoutException this indicates that Astersik >> does not >> return a Response to your Action. >> I just tried your code with Asterisk CVS-HEAD and it I dont get any >> timeout. What version of Asterisk and Asterisk-Java do you use? >> >> It would help if you could send me a trace of the conversation >> between >> Asterisk and your application. >> I usually generate them using ngrep on my Asterisk server >> (ngrep -s 4000 port 5038 works well). >> Then we can quickly see the cause of this problem. >> >> =Stefan >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.2 (MingW32) >> Comment: GnuPT 2.7.2 >> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org >> >> iD8DBQFDcIrSTUZ7XZofpgURAtaEAKCcVYMBzdjYOjJmxgvGW02B0JRi9QCgv+HM >> OI5pyRbOG6hc0MoeqpyXLPk= >> =cwpS >> -----END PGP SIGNATURE----- >> >> >> ------------------------------------------------------- >> SF.Net email is sponsored by: >> Tame your development challenges with Apache's Geronimo App >> Server. Download >> it for free - -and be entered to win a 42" plasma tv or your very own >> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >> >> > > > > --__--__-- > > Message: 5 > From: Gerwin Bruner <ger...@gm...> > Subject: Re: [Asterisk-java-users] Set Global Variable via Manager API > Date: Tue, 8 Nov 2005 12:47:39 +0100 > To: ast...@li... > Reply-To: ast...@li... > > Great, > > thanks very much. > > Gerwin > > On Nov 8, 2005, at 12:41 PM, Stefan Reuter wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Stefan Reuter schrieb: >>> I just posted >>> http://bugs.digium.com/view.php?id=5571 >>> to fix the SetVar. >> >> That patch has been accepted by digium. >> So when using latest CVS-HEAD of Asterisk the channel property of the >> SetVarAction is optional. To set a global variable only set the >> variable >> and value properties of SetVarAction and leave channel empty. >> I just updated Asterisk-Java's javadoc and added a convenience >> constructor to SetVarAction that takes a variable and value. >> >> =Stefan >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.2 (MingW32) >> Comment: GnuPT 2.7.2 >> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org >> >> iD8DBQFDcI7TTUZ7XZofpgURAq4LAKDAiWtVNpahbdpELxeUYll6Q+zv7QCgh9aF >> am3AIWHrbzVVTWbGHuv8gng= >> =1tGM >> -----END PGP SIGNATURE----- >> >> >> ------------------------------------------------------- >> SF.Net email is sponsored by: >> Tame your development challenges with Apache's Geronimo App Server. >> Download >> it for free - -and be entered to win a 42" plasma tv or your very own >> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > --__--__-- > > Message: 6 > Date: Tue, 08 Nov 2005 14:29:21 +0100 > From: Stefan Reuter <sr...@re...> > To: ast...@li... > Subject: Re: [Asterisk-java-users] Timeout when hanging up > Reply-To: ast...@li... > > This is an OpenPGP/MIME signed message (RFC 2440 and 3156) > --------------enig5EA84A11294D8A07638B4E7E > Content-Type: text/plain; charset=ISO-8859-1 > Content-Transfer-Encoding: 7bit > > Hi Brett, > > thank you for the trace. > Everything behaves correctly. I just had my brain switched off ;) > > At first some background information about how Asterisk-Java works: > Generally when using the ManagerConnection there are two threads > involved. Your "normal" application thread ("Main") and an addtional > thread for the ManagerReader. > The ManagerReader thread reads repsonses and events from Asterisk and > dispatches them to the event and repsonse handlers. > > What happened in your case is the following: > > You register an event handler that is called on a NewChannelEvent. > This > event hanler is called from the ManagerReader thread. Now you send a > HangupAction to Asterisk and wait for the response. The response can > only be read and dispatched by the ManagerReader thread but that > ManagerReader thread is already blocked waiting for the response... a > deadlock. > > So what to do in such a case? > Generally don't do anything that blocks the ManagerReader thread in > event handlers. So you have two options: > a) send the HangupAction in a non-blocking way: > managerConnection.sendAction(hangup, null); > b) create an additional thread that does the hangup and only > asynchronously inform that thread in your handleEvent() method > > I think a) will be sufficient in this case. (but you loose the > resposne > to the hangup action) > > =Stefan > > > > --------------enig5EA84A11294D8A07638B4E7E > Content-Type: application/pgp-signature; name="signature.asc" > Content-Description: OpenPGP digital signature > Content-Disposition: attachment; filename="signature.asc" > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2 (MingW32) > Comment: GnuPT 2.7.2 > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFDcKg4TUZ7XZofpgURAqOmAKCISuhst/Gy9UQaIA+IVMA6lHDU4gCfV1N/ > xqm9JZZ+k5wAQ0hBUqHPn8w= > =dJKr > -----END PGP SIGNATURE----- > > --------------enig5EA84A11294D8A07638B4E7E-- > > > --__--__-- > > Message: 7 > Date: Wed, 09 Nov 2005 08:52:51 +1100 > From: Brett Sutton <bs...@no...> > To: ast...@li... > Subject: Re: [Asterisk-java-users] Timeout when hanging up > Reply-To: ast...@li... > > Thanks for your help. > I don't think you were the only one with you brain switched off, now > that you point it out the problem is obvious. > > I'm not terribly interested in the result of the hangup so I would > agree > option 'a' should work nicely. > > Once again many thanks for you help. > Brett. > > > Stefan Reuter wrote: > >> Hi Brett, >> >> thank you for the trace. >> Everything behaves correctly. I just had my brain switched off ;) >> >> At first some background information about how Asterisk-Java works: >> Generally when using the ManagerConnection there are two threads >> involved. Your "normal" application thread ("Main") and an addtional >> thread for the ManagerReader. >> The ManagerReader thread reads repsonses and events from Asterisk and >> dispatches them to the event and repsonse handlers. >> >> What happened in your case is the following: >> >> You register an event handler that is called on a NewChannelEvent. >> This >> event hanler is called from the ManagerReader thread. Now you send a >> HangupAction to Asterisk and wait for the response. The response can >> only be read and dispatched by the ManagerReader thread but that >> ManagerReader thread is already blocked waiting for the response... a >> deadlock. >> >> So what to do in such a case? >> Generally don't do anything that blocks the ManagerReader thread in >> event handlers. So you have two options: >> a) send the HangupAction in a non-blocking way: >> managerConnection.sendAction(hangup, null); >> b) create an additional thread that does the hangup and only >> asynchronously inform that thread in your handleEvent() method >> >> I think a) will be sufficient in this case. (but you loose the >> resposne >> to the hangup action) >> >> =Stefan >> >> >> >> > > > > > --__--__-- > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > End of Asterisk-java-users Digest |
From: Brett S. <bs...@no...> - 2005-11-08 21:53:10
|
Thanks for your help. I don't think you were the only one with you brain switched off, now that you point it out the problem is obvious. I'm not terribly interested in the result of the hangup so I would agree option 'a' should work nicely. Once again many thanks for you help. Brett. Stefan Reuter wrote: >Hi Brett, > >thank you for the trace. >Everything behaves correctly. I just had my brain switched off ;) > >At first some background information about how Asterisk-Java works: >Generally when using the ManagerConnection there are two threads >involved. Your "normal" application thread ("Main") and an addtional >thread for the ManagerReader. >The ManagerReader thread reads repsonses and events from Asterisk and >dispatches them to the event and repsonse handlers. > >What happened in your case is the following: > >You register an event handler that is called on a NewChannelEvent. This >event hanler is called from the ManagerReader thread. Now you send a >HangupAction to Asterisk and wait for the response. The response can >only be read and dispatched by the ManagerReader thread but that >ManagerReader thread is already blocked waiting for the response... a >deadlock. > >So what to do in such a case? >Generally don't do anything that blocks the ManagerReader thread in >event handlers. So you have two options: >a) send the HangupAction in a non-blocking way: >managerConnection.sendAction(hangup, null); >b) create an additional thread that does the hangup and only >asynchronously inform that thread in your handleEvent() method > >I think a) will be sufficient in this case. (but you loose the resposne >to the hangup action) > >=Stefan > > > > |
From: Stefan R. <sr...@re...> - 2005-11-08 13:30:01
|
Hi Brett, thank you for the trace. Everything behaves correctly. I just had my brain switched off ;) At first some background information about how Asterisk-Java works: Generally when using the ManagerConnection there are two threads involved. Your "normal" application thread ("Main") and an addtional thread for the ManagerReader. The ManagerReader thread reads repsonses and events from Asterisk and dispatches them to the event and repsonse handlers. What happened in your case is the following: You register an event handler that is called on a NewChannelEvent. This event hanler is called from the ManagerReader thread. Now you send a HangupAction to Asterisk and wait for the response. The response can only be read and dispatched by the ManagerReader thread but that ManagerReader thread is already blocked waiting for the response... a deadlock. So what to do in such a case? Generally don't do anything that blocks the ManagerReader thread in event handlers. So you have two options: a) send the HangupAction in a non-blocking way: managerConnection.sendAction(hangup, null); b) create an additional thread that does the hangup and only asynchronously inform that thread in your handleEvent() method I think a) will be sufficient in this case. (but you loose the resposne to the hangup action) =Stefan |