Re: [Asterisk-java-devel] How to receive "No route to Host / Network Disconnection / ..." events?
Brought to you by:
srt
From: Yves A. <yv...@gm...> - 2014-07-29 10:21:06
|
Hi, you should be able to catch a DisconnectEvent if you have a Listener attached. This event is fired whenever the connection to your asterisks breaks down. On a successful reconnect you will receive an ConnectEvent. In my experience, AsteriskJava only detects a failure, when you try to send a Command or an Action... as long as you do nothing, AsteriskJava thinks, it´s connected and the ManagerConnection.getState() always returns "CONNECTED"... at least for a very very long time. So, if you depend on "almost-realtime" Event for Network-Failure beeing fired, you should periodically do some action on your ManagerConnection... e.g. in a Thread. yves Am 29.07.2014 um 11:13 schrieb Jose Baez: > Oh, sorry for asnwering so late. I was looking into my logs to > copypaste those errors... > > Asterisk-java is running on 1 machine and Asterisk-AMI is running on > other machine (IP 2). > > If network fails, or Asterisk fails or IP-2 machine freezes, > asterisk-java throws these errors because it cannot connect to Asterisk: > > > INFO: Connecting to 172.xxxxxxxx:5038 > Jul 24, 2014 4:29:25 PM > org.asteriskjava.manager.internal.ManagerConnectionImpl reconnect > WARNING: Exception while trying to reconnect: *Connection timed out* > WARNING: Exception while trying to reconnect: *Connection timed out* > WARNING: Exception while trying to reconnect: *Connection timed out* > ... > ... > > Jul 24, 2014 4:30:48 PM > org.asteriskjava.manager.internal.ManagerConnectionImpl reconnect > WARNING: Exception while trying to reconnect: *No route to host* > WARNING: Exception while trying to reconnect: *No route to host* > WARNING: Exception while trying to reconnect: *No route to host* > ... > ... > INFO: Connecting to 172.xxxxxxxx:5038 > Jul 24, 2014 4:32:05 PM > org.asteriskjava.manager.internal.ManagerConnectionImpl connect > INFO: Connecting to 172.xxxxxxxx:5038 > Jul 24, 2014 4:32:05 PM > org.asteriskjava.manager.internal.ManagerConnectionImpl > setProtocolIdentifier > INFO: Connected via Asterisk Call Manager/1.3 > Jul 24, 2014 4:32:05 PM > org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin > INFO: *Successfully logged in* > > > How could I retrieve those warnings in my Java code? I would like to > run a few checks on Asterisk. > > If Asterisk failed it means audio calls have all finished and I must > cleared a few variables in Java. > > > > > On 25 July 2014 15:30, Yves A. <yv...@gm... > <mailto:yv...@gm...>> wrote: > > Could you please go a bit more into detail? > which "network errors events" are you talking about? > > yves > > Am 25.07.2014 um 13:22 schrieb Jose Baez: >> Hello! >> >> How can I get network errors events sent by asterisk-java library? >> >> I would like to check a few variables after one of those errors >> occur, to know if Asterisk failed or it was just a network hiccup. >> >> >> Thank you. >> >> >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> Want fast and easy access to all the code in your enterprise? Index and >> search up to 200,000 lines of code with a free copy of Black Duck >> Code Sight - the same software that powers the world's largest code >> search on Ohloh, the Black Duck Open Hub! Try it now. >> http://p.sf.net/sfu/bds >> >> >> _______________________________________________ >> Asterisk-java-devel mailing list >> Ast...@li... <mailto:Ast...@li...> >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > ------------------------------------------------------------------------------ > Want fast and easy access to all the code in your enterprise? > Index and > search up to 200,000 lines of code with a free copy of Black Duck > Code Sight - the same software that powers the world's largest code > search on Ohloh, the Black Duck Open Hub! Try it now. > http://p.sf.net/sfu/bds > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel > > > > > ------------------------------------------------------------------------------ > Infragistics Professional > Build stunning WinForms apps today! > Reboot your WinForms applications with our WinForms controls. > Build a bridge from your legacy apps to the future. > http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk > > > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel |