Thread: [Asterisk-java-users] Manager API logged off automatically
Brought to you by:
srt
From: Peter H. <pe...@li...> - 2005-07-16 01:18:05
|
Hi All, I'm new to asterisk and java/asterisk. I've been playing around with it = for about 2 days now.. I've successfully used the Manager API to login, = and perform some asterisk actions. However, I noticed that my Manager API logs off the asterisk server = after a certain amount of time. Is there a setting on the Asterisk server that logs off a manager API = connection after it is idle? Is this a setting in the manager API class? I could find references to this subject in either documentation, nor in = the archives. I'm hoping to set up the Manager API server so it only needs to log in = once, and listen to events for the duration it is running. I'd appreciate any insight into this. Thanks, Peter Hsu |
From: Stefan R. <sr...@re...> - 2005-07-16 12:03:39
|
> However, I noticed that my Manager API logs off the asterisk server > after a certain amount of time. hmm what amout of time? > Is there a setting on the Asterisk server that logs off a manager API > connection after it is idle? In the case Asterisk-Java gets disconnected for whatever reason it will automatically reconnect... =20 > Is this a setting in the manager API class? No, autoreconnect is a basic feature of the ManagerConnection. What you can configure is if Asterisk-Java should also try to reconnect when authentication fails. That is disabled by default and can be enabled by using DefaultManagerConnection's setKeepAliveAfterAuthenticationFailure() method. > I could find references to this subject in either documentation, nor > in the archives. > =20 > I'm hoping to set up the Manager API server so it only needs to log in > once, and listen to events for the duration it is running. Thats the way it should work ;) To help you regarding this issue I need some further information. Please enable logging and send me the logs. The best way to do this is to include the log4j jar in your classpath along with log4.properties file that might look like this: log4j.rootCategory=3DINFO, File log4j.appender.File =3D org.apache.log4j.FileAppender log4j.appender.File.file =3D asterisk-java.log log4j.appender.File.append =3D false log4j.appender.File.layout =3D org.apache.log4j.PatternLayout log4j.appender.File.layout.ConversionPattern =3D %d %c %p - %m\n =3DStefan |
From: Peter H. <pe...@li...> - 2005-07-16 17:18:47
Attachments:
asterisk-java-1.log
|
Stefan, Thanks for the response.. Before I continue, I should mention that I'm using the 0.10 release and asterisk 1.0.9 - in case that throws up any flags. Also, I am running the manager API from a remote machine at the moment. The Manager API gets logged off in under 10 minutes. It seems to be pretty consistent at 7 minutes, but I can't get an exact snapshot of the time. The manager API doesn't seem to get notified that it is logged off. This is what is seen on the asterisk server side using the option -vvvc: == Parsing '/etc/asterisk/manager.conf': Found == Manager 'pdc' logged on from xx.xx.xx.xx == Manager 'pdc' logged off from xx.xx.xx.xx This is my log on the manager side. 2005-07-16 09:21:13,546 net.sf.asterisk.manager.DefaultManagerConnection INFO - Connecting to yy.yy.yy.yy port 5038 net.sf.asterisk.manager.event.ConnectEvent: dateReceived=Sat Jul 16 09:21:33 PDT 2005; systemHashcode=24670264 2005-07-16 09:21:33,484 net.sf.asterisk.manager.DefaultManagerConnection INFO - Connected via Asterisk Call Manager/1.0 2005-07-16 09:21:33,828 net.sf.asterisk.manager.DefaultManagerConnection INFO - Successfully logged in I've set the logging level to DEBUG, but nothing interesting came up. As I mentioned, it doesn't seem to know that it's gotten logged off. I'm using really basic java code to establish the connection: ManagerConnectionFactory factory = new ManagerConnectionFactory(); ManagerConnection managerConnection = factory.getManagerConnection("yy.yy.yy.yy", "username", "secret"); ManagerConnection managerConnection.login(); // Do nothing and wait On the same topic, there is another issue that presents itself when the manager is in this state. When I send a subsequent action, the Manager will reconnect, but the action will always timeout. I've set the timeout value on the action to an arbitrarily high amount. However, the action will always time out when sent in this state. 2005-07-16 09:58:09,453 net.sf.asterisk.manager.impl.ManagerReaderImpl INFO - IOException while reading from asterisk server, terminating reader thread: Connect 2005-07-16 09:58:09,453 net.sf.asterisk.manager.DefaultManagerConnection INFO - Closing socket. 2005-07-16 09:58:09,515 net.sf.asterisk.manager.DefaultManagerConnection INFO - Connecting to 63.198.100.59 port 5038 2005-07-16 09:58:29,062 net.sf.asterisk.manager.DefaultManagerConnection INFO - Connected via Asterisk Call Manager/1.0 2005-07-16 09:58:29,265 net.sf.asterisk.manager.DefaultManagerConnection INFO - Successfully logged in 2005-07-16 09:58:29,265 net.sf.asterisk.manager.DefaultManagerConnection INFO - Successfully reconnected. Exception in thread "main" net.sf.asterisk.manager.TimeoutException: Timeout waiting for response to Originate at net.sf.asterisk.manager.DefaultManagerConnection.sendAction(DefaultManagerConnection.java:421) at net.pdc.asterisk.Test.run(Test.java:93) at net.pdc.asterisk.Test.main(Test.java:200) I've attached the entire log file. Peter |
From: Stefan R. <sr...@re...> - 2005-07-16 19:44:13
Attachments:
PingThread.java
|
> Before I continue, I should mention that I'm using the 0.10 release and > asterisk 1.0.9 - in case that throws up any flags. Also, I am running the > manager API from a remote machine at the moment. Thats fine, same here :) > The Manager API gets logged off in under 10 minutes. It seems to be pretty > consistent at 7 minutes, but I can't get an exact snapshot of the time. The only difference to my setup might be that I have constant traffic on my ManagerConnection due to SIP and IAX peer, registry, whatever events. That doesn't seem to be the case with you as there is no activity in log between 2005-07-16 09:21:33,828 and 2005-07-16 09:31:04,062. Maybe there is some kind of networking device between you and the Asterisk server (a firewall?) that kills the connection. What you can do is to send PingActions to Asterisk to generate this traffic. I attached an example of such a PingThread that might be useful for you. Use it as follows: c = new ManagerConnectionFactory().getManagerConnection(...); c.login(); PingThread pingThread = new PingThread(c); pingThread.start(); [...] pingThread.die(); c.logoff(); > On the same topic, there is another issue that presents itself when the > manager is in this state. When I send a subsequent action, the Manager will > reconnect, but the action will always timeout. I've set the timeout value > on the action to an arbitrarily high amount. However, the action will > always time out when sent in this state. Hmmmmm lets see if the PingThread solves your problem and if not dive into this issue as well. =Stefan |
From: Peter H. <pe...@li...> - 2005-07-16 20:27:04
|
Stefan, You're right - it was a firewall setting. I'm confident that the PingThread solution will solve my problem... that was my next option after checking if I was missing some configuration setting. The PingThread should also help avoid the 2nd problem, because the manager should try to reconnect if it's disconnected, I'm guessing, but it would be nice if the manager could catch that loss of connection as well, in case of network outtages (or something). Aside from this issue, asterisk-java is great - thanks. Peter ----- Original Message ----- From: "Stefan Reuter" <sr...@re...> To: <ast...@li...> Sent: Saturday, July 16, 2005 12:43 PM Subject: Re: [Asterisk-java-users] Manager API logged off automatically > Before I continue, I should mention that I'm using the 0.10 release and > asterisk 1.0.9 - in case that throws up any flags. Also, I am running the > manager API from a remote machine at the moment. Thats fine, same here :) > The Manager API gets logged off in under 10 minutes. It seems to be > pretty > consistent at 7 minutes, but I can't get an exact snapshot of the time. The only difference to my setup might be that I have constant traffic on my ManagerConnection due to SIP and IAX peer, registry, whatever events. That doesn't seem to be the case with you as there is no activity in log between 2005-07-16 09:21:33,828 and 2005-07-16 09:31:04,062. Maybe there is some kind of networking device between you and the Asterisk server (a firewall?) that kills the connection. What you can do is to send PingActions to Asterisk to generate this traffic. I attached an example of such a PingThread that might be useful for you. Use it as follows: c = new ManagerConnectionFactory().getManagerConnection(...); c.login(); PingThread pingThread = new PingThread(c); pingThread.start(); [...] pingThread.die(); c.logoff(); > On the same topic, there is another issue that presents itself when the > manager is in this state. When I send a subsequent action, the Manager > will > reconnect, but the action will always timeout. I've set the timeout value > on the action to an arbitrarily high amount. However, the action will > always time out when sent in this state. Hmmmmm lets see if the PingThread solves your problem and if not dive into this issue as well. =Stefan |
From: Stefan R. <sr...@re...> - 2005-07-18 11:58:41
|
Hi Peter, > but it would be > nice if the manager could catch that loss of connection as well, in cas= e > of network outtages (or something). agreed. I thought we would always get an IOException at least when trying to write to the socket while the connection is lost. That works fine righ= t now if Asterisk is shutdown and restarted. I will take a closer look at what happens when I just unplug the network cable from my Asterisk server when I get some time but its not 1st prio. I'll keep you informed on the results. > Aside from this issue, asterisk-java is great - thanks. thats nice to hear :) =3DStefan |