1

Is there a way in Asterisk, how to detect proper status of the manager's connection to the Asterisk? (my point is the notification about failed connection to asterisk) I'm implementing visual indication to our java application (using Asterisk Java library), however from my point of view it is not working as one would expect.

There is a method getStatus() on ManagerConnection, but even if I disconnect network cable, the result is always CONNECTED. And I haven't observed anything similar I could use.

gurbi
  • 163
  • 2
  • 14

1 Answers1

1

Simple way:

  • set global variable PING in extensions.conf to 1
  • via manager get global variable value. If not 1, re-connect.
arheops
  • 15,544
  • 1
  • 21
  • 27
  • 1
    I admit, it is simple solution and is working. However, it is also the most ugly one. If there is no connection, I get ManagerCommunicationException - which means I'm using exception handling to handle also my regular workflow. Is there also some not-so-simple, but more apropriate solution? – gurbi Mar 03 '14 at 10:45
  • I not understand what is problem handle your exception. I am sorry, i am not familar with java nor with your java library. You also can read library code(it is opensource) and add connection check routine. – arheops Mar 03 '14 at 13:15
  • Or hire expert who teach you how work with java exceptions/extend java class. – arheops Mar 03 '14 at 13:16
  • :) It is not, that I don't know how to handle exceptions in java - I know them too well. That's the reason, why I want to avoid them - using exceptions for regular workflow (which disconnection is) is not something I would like to do. See [here](http://stackoverflow.com/questions/2184935/performance-cost-of-coding-exception-driven-development-in-java) and [here](http://stackoverflow.com/questions/299068/how-slow-are-java-exceptions). I just hoped someone would have an idea, why calling ManagerConnection.getStatus() will not return DISCONNECTED after some time, or come up with smthg similar. – gurbi Mar 04 '14 at 06:46
  • I not understand your problem. Ask library dev lib why they do so or rewrite source code, it is OPEN SOURCE. – arheops Mar 04 '14 at 10:12