[Asterisk-java-users] Re: DefaultAGIServer bind exception
Brought to you by:
srt
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 |