asterisk-java-users Mailing List for Asterisk-Java Library (Page 153)
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: Henry S. <hen...@gm...> - 2006-04-03 09:17:02
|
Hi Peter, thx for the excellent clarification and for the link for ast-console. Here some additional information about what i am trying to do ( i think it is something similar to the ast-console). May be you can give me a hint ( i am a little confused and don't know what to use (with or without threads). I have a main that only does one thing -------------------------------Main----------------------------------------= -------------------------------------------- public class Main { public static void main(String args[]) { LogIn logIn =3D new LogIn(); } } ---------------------------------------------------------------------------= ------------------------------------------------ In my LogIn i have a JTextField for the username, a JPasswordField for the password and an editable JComboBox with some predefined IP@ (or you can enter your IP@). With a JButton i am able to login into my Asterisk server. ------------------------------LogIn----------------------------------------= -------------------------------------------- sButtonOk.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent Event) { if((sTextFieldUser.getText().equals("")) || ( sTextFieldPasswd.getText().equals(""))) { JOptionPane.showMessageDialog(new JFrame(), "Required field cannot be left blank.\nEnter username AND password.","Error Message",JOptionPane.ERROR_MESSAGE); } else { try { AMILogin amiLogin =3D new AMILogin(); =20 amiLogin.getCredentials((String)sComboDomain.getSelectedItem(), sTextFieldUser.getText(), sTextFieldPasswd.getText()); amiLogin.logIn(); if(amiLogin.checkLogin()) { JOptionPane.showMessageDialog(new JFrame(),"Successfully logged in","Login Message.", JOptionPane.INFORMATION_MESSAGE); //System.out.println("Successfully logged in!!!!!"); setVisible(false); dispose(); MainPage mainPage =3D new MainPage(); } } catch (TimeoutException e) { JOptionPane.showMessageDialog(new JFrame(),"Error: Connection Timed out","Error Message.", JOptionPane.ERROR_MESSAGE); System.out.println("Error: "+e.getMessage()); } catch (AuthenticationFailedException e) { JOptionPane.showMessageDialog(new JFrame(),"Error: Authentication Failed.","Error Message", JOptionPane.ERROR_MESSAGE); System.out.println("Error: "+e.getMessage()); } catch (IOException e) { JOptionPane.showMessageDialog(new JFrame(),"Error: Connection Failed.","Error Message", JOptionPane.ERROR_MESSAGE); System.out.println("Error: "+e.getMessage()); } } } }); ---------------------------------------------------------------------------= ------------------------------------------------ I have changed the AMILogin as suggested in your post (no inheritance from java.lang.Thread.). ------------------------------AMILogin-------------------------------------= ----------------------------------------------- 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.TimeoutException; public class AMILogin { String userName; String hostName; String passWord; ManagerConnection managerConnection; ManagerConnectionFactory factory; public void logIn() throws IOException, AuthenticationFailedException, TimeoutException { factory =3D new ManagerConnectionFactory(); this.managerConnection =3D factory.getManagerConnection(hostName, userName, passWord); managerConnection.login(); } public boolean checkLogin() { if(managerConnection.isConnected()) return true; else return false; } public void getCredentials(String h, String u, String p) { userName =3D u; hostName =3D h; passWord =3D p; } public void logOff()throws java.io.IOException, TimeoutException { managerConnection.logoff(); } } ---------------------------------------------------------------------------= ------------------------------------------------ Finally i have a MainPage with one JFrame, a JTextArea and a JButton for th= e logoff. ------------------------------------------MainPage-------------------------= ------------------------------------------- sButtonLogoff.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent Event) { AMILogin amiLogoff; try { amiLogoff =3D new AMILogin(); amiLogoff.logOff(); } catch (TimeoutException e) { JOptionPane.showMessageDialog(new JFrame(),"Error: Connection Timed out","Error Message.", JOptionPane.ERROR_MESSAGE); System.err.println("Error: "+e.getMessage()); } catch (IOException e) { JOptionPane.showMessageDialog(new JFrame(),"Error: Connection Failed.","Error Message", JOptionPane.ERROR_MESSAGE); System.err.println("Error: "+e.getMessage()); } } }); ---------------------------------------------------------------------------= ------------------------------------------------ Unfortunately i still have the NullPointerException. Sorry, but i don't kno= w where to start my troubleshooting... On 4/1/06, Peter Hoppe <pe...@ra...> wrote: > > Dear Henry, > > thanks for your message! First of all, hats off - you do very well as a > newcomer to Java! > > First of all , run() is a method used with threads. If you intend to use > threads, you need to inherit your class from java.lang.Thread like so: > > public class AMILogin extends Thread > { > ... > } > > This class would then contain the run() method. To instantiate your > class and start the thread you would then do this: > > AMILogin myLogin =3D null; > > myLogin =3D new AMILogin (); > myLogin.getCredentials ("192.168.10.12", "admin", "admin"); > myLogin.start; // -> This calls the run() method and starts the thread! > > > Since you used the run() method and your exception message showed traces > of GUI activity while at the same time AMILogin doesn't extend > java.lang.Thread, I followed two possible scenarios: > > a) Class AMILogin is a stand-alone class having no inheritance from > java.lang.Thread. > To make this work, I > * I added a main() method > * I changed the name of the run() method to login() > * instantiated AMILogin, did a login and exited. > > With this approach I had no errors. > > > b) Class AMILogin does inherit from java.lang.Thread. > * I added a main() method > * Program instantiated AMILogin and started the thread. > * Program logged off immediately. > > With this approach I got a NullPointerException in the logOff > method as indicated. > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > Approach a: No java.lang.Thread: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --------------- source code 1 start ----------------------------- > > package org.rww.asterisk.trials; > > 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.TimeoutException; > > public class AMILogin > { > String userName; > > String hostName; > > String passWord; > > ManagerConnection managerConnection; > > ManagerConnectionFactory factory; > > public void login() throws IOException, AuthenticationFailedException= , > TimeoutException > { > factory =3D new ManagerConnectionFactory(); > this.managerConnection =3D factory.getManagerConnection(hostName, > userName, passWord); > managerConnection.login(); > } > > public boolean checkLogin() > { > if (managerConnection.isConnected()) > return true; > else > return false; > } > > public void getCredentials(String h, String u, String p) > { > userName =3D u; > hostName =3D h; > passWord =3D p; > } > > public void logOff() throws java.io.IOException, TimeoutException > { > managerConnection.logoff(); > } > > public static void main (String [] args) > { > AMILogin l; > > try > { > l =3D new AMILogin (); > l.getCredentials("192.168.10.12", "admin", "admin"); > System.out.println("=3D=3D=3D=3D=3D=3D=3D> logging in <=3D= =3D=3D=3D=3D=3D=3D"); > l.login(); > System.out.println("\n=3D=3D=3D=3D=3D=3D=3D> logging out <=3D= =3D=3D=3D=3D=3D=3D"); > l.logOff(); > } > catch (IOException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > catch (AuthenticationFailedException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > catch (TimeoutException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > catch (InterruptedException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > } > } > > --------------- source code 1 end ----------------------------- > > The corresponding console output is: > > --------------- output 1 start --------------------------- > > =3D=3D=3D=3D=3D=3D=3D> logging in <=3D=3D=3D=3D=3D=3D=3D > 01-Apr-2006 12:55:14 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connecting to 192.168.10.12 port 5038 > 01-Apr-2006 12:55:27 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connected via Asterisk Call Manager/1.0 > 01-Apr-2006 12:55:27 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Successfully logged in > 01-Apr-2006 12:55:27 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Determined Asterisk version: Asterisk 1.0 > > =3D=3D=3D=3D=3D=3D=3D> logging out <=3D=3D=3D=3D=3D=3D=3D > 01-Apr-2006 12:55:32 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Reached end of stream, terminating reader. > 01-Apr-2006 12:55:32 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Closing socket. > > --------------- output 1 end --------------------------- > > > So it worked on my machine. > > > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > Approach b: inherit from java.lang.Thread: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --------------- source code 2 start ----------------------------- > > package org.rww.asterisk.trials; > > 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.TimeoutException; > > public class AMILogin extends Thread > { > String userName; > > String hostName; > > String passWord; > > ManagerConnection managerConnection; > > ManagerConnectionFactory factory; > > public void run() > { > factory =3D new ManagerConnectionFactory(); > try > { > this.managerConnection =3D factory.getManagerConnection > (hostName, > userName, passWord); > managerConnection.login(); > } > catch (IOException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > catch (AuthenticationFailedException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > catch (TimeoutException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > } > > public boolean checkLogin() > { > if (managerConnection.isConnected()) > return true; > else > return false; > } > > public void getCredentials(String h, String u, String p) > { > userName =3D u; > hostName =3D h; > passWord =3D p; > } > > public void logOff() throws java.io.IOException, TimeoutException > { > managerConnection.logoff(); > } > > public static void main (String [] args) > { > AMILogin l; > > try > { > l =3D new AMILogin (); > l.getCredentials("192.168.10.12", "admin", "admin"); > System.out.println("=3D=3D=3D=3D=3D=3D=3D> logging in <= =3D=3D=3D=3D=3D=3D=3D"); > l.start(); > > System.out.println("\n=3D=3D=3D=3D=3D=3D=3D> logging out = <=3D=3D=3D=3D=3D=3D=3D"); > l.logOff(); > } > catch (IOException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > catch (TimeoutException e) > { > // TODO Auto-generated catch block > e.printStackTrace(); > } > > } > } > > --------------- source code 2 end ----------------------------- > > Lo and behold, now the corresponding console output goes like this: > > --------------- output 1 start --------------------------- > > =3D=3D=3D=3D=3D=3D=3D> logging in <=3D=3D=3D=3D=3D=3D=3D > > =3D=3D=3D=3D=3D=3D=3D> logging out <=3D=3D=3D=3D=3D=3D=3D > Exception in thread "main" java.lang.NullPointerException > at org.rww.asterisk.trials.AMILogin.logOff(AMILogin.java:70) > at org.rww.asterisk.trials.AMILogin.main(AMILogin.java:85) > 01-Apr-2006 13:01:44 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connecting to 192.168.10.12 port 5038 > 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connected via Asterisk Call Manager/1.0 > 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Successfully logged in > 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Determined Asterisk version: Asterisk 1.0 > > --------------- output 1 end --------------------------- > > So, now I got the desired NullPointerException! The reason for this lies > in the timing: The statements in the main() method: > > l =3D new AMILogin (); > l.getCredentials("192.168.10.12", "admin", "admin"); > System.out.println("=3D=3D=3D=3D=3D=3D=3D> logging in <= =3D=3D=3D=3D=3D=3D=3D"); > l.start(); > > System.out.println("\n=3D=3D=3D=3D=3D=3D=3D> logging out = <=3D=3D=3D=3D=3D=3D=3D"); > l.logOff(); > > make the following sequence happen: > > 1. Create new AMILogin > 2. Get Credentials > 3. Print "=3D=3D=3D=3D=3D=3D=3D> logging in <=3D=3D=3D=3D=3D=3D=3D"; > 4. Start Thread and RETURN IMMEDIATELY (!!) > > Now, my new AMILogin Thread starts. It > 4.1. Logs into the asterisk server > 4.2. Waits (!!) for the asterisk server's response > > At point 4.2., no ManagerConnection object exists yet as the call to > this.managerConnection =3D factory.getManagerConnection(hostName, > userName, passWord); > > hasn't returned and won't be for the next few seconds. Therefore the > AMILogin member > managerConnection > > remains null until the server has answered. > > > But our main() function doesn't wait. Meanwhile it continues: > 5. Print "\n=3D=3D=3D=3D=3D=3D=3D> logging out <=3D=3D=3D=3D=3D=3D=3D" > 6. Call logoff (); > > And at this point, We get the NullPointerException, because in logOff() > we call > managerConnection.logoff(); > > on a non-existing object, as managerConnection is still null (since we > are still waiting for the asterisk server's response). > > > Then a few seconds later, the server does respond: > 01-Apr-2006 13:01:44 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connecting to 192.168.10.12 port 5038 > 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connected via Asterisk Call Manager/1.0 > 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Successfully logged in > 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Determined Asterisk version: Asterisk 1.0 > > But now it's too late. > > What we have here is called a race condition - two thread race against > each other and our application gets into a bad state. This is because > the start() call is an asynchronous call - it sends the start message to > the thread object and returns immediately. The opposite would be a > synchronous call where the caller waits for the callee to finish. > Programming wise, a call to a method / function is mostly synchronous, > as the caller waits for the function to return. > > Some examples to illustrate this: > > Asynchronous call: Your boss asks you to create this report (will take > four to six weeks to completion) and comes back the next day to get the > result. > Synchronous call: Your boss asks you to create this report (will take > four to six weeks to completion) and waits for you to come back to him > and then asks you for the result. > > In this example, the main() function is like that impatient boss - it > tells your poor AMILogin object to login, but then doesn't wait and > immediately wants to log out. AMILogin object shouts in protest - > NullPointerException! as much as our poor employee would answer that > impatient boss: "Sorry, NullReportException". > > Asynchronous call: You order a pizza by phone from a pizza shop. You > know the pizza will come some time later and forget about the call and > watch the news meanwhile. > Synchronous call: You go into a pizza restaurant, sit down at a table, > order a pizza and WAIT for the pizza to be finished. You certainly won't > forget the order, as you can't do anything until the pizza's done. > > > > As I say, I don't know which scenario (threaded/non threaded) applies to > your situation. But I hope this information helps. > > But there are two example applications on asterisk-java - head to > http://svn.reucon.net/repos/asterisk-java-examples/trunk/ > > the ast-console application contains a longer text in the /doc directory > explaining the application. > > > Thanks again for your message! > > > God bless, > > Peter > > > -- > dyslexics of the world - untie ! > > > > > Hi all, > > i'am new to asterisk-java (to be honest to java too), so please be > clement. > > I am able to logon into my Asterisk server but have problem to logoff. > > > > #java Main > > 31 mars 2006 16:11:36 net.sf.asterisk.util.impl.JavaLoggingLog info > > INFO: Connecting to 192.168.204.223 port 5038 > > 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info > > INFO: Connected via Asterisk Call Manager/1.0 > > 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info > > INFO: Successfully logged in > > 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info > > INFO: Determined Asterisk version: Asterisk 1.0 > > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > > at AMILogin.logOff(AMILogin.java:36) > > at MainPage$1.mouseClicked(MainPage.java:50) > > at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source) > > at java.awt.Component.processMouseEvent(Unknown Source) > > at javax.swing.JComponent.processMouseEvent(Unknown Source) > > at java.awt.Component.processEvent(Unknown Source) > > at java.awt.Container.processEvent(Unknown Source) > > at java.awt.Component.dispatchEventImpl(Unknown Source) > > at java.awt.Container.dispatchEventImpl(Unknown Source) > > at java.awt.Component.dispatchEvent(Unknown Source) > > at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown > Source=3D > > ) > > at java.awt.LightweightDispatcher.processMouseEvent(Unknown > Source) > > at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) > > at java.awt.Container.dispatchEventImpl(Unknown Source) > > at java.awt.Window.dispatchEventImpl(Unknown Source) > > at java.awt.Component.dispatchEvent(Unknown Source) > > at java.awt.EventQueue.dispatchEvent(Unknown Source) > > at > java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown So=3D > > urce) > > > > at > java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Sour=3D > > ce) > > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > > at java.awt.EventDispatchThread.run(Unknown Source) > > > > > > here what i have... > > > > > > 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.TimeoutException; > > > > public class AMILogin > > { > > String userName; > > String hostName; > > String passWord; > > ManagerConnection managerConnection; > > ManagerConnectionFactory factory; > > > > public void run() throws IOException, AuthenticationFailedException, > > TimeoutException > > { > > factory =3D3D new ManagerConnectionFactory(); > > this.managerConnection =3D3D factory.getManagerConnection(hostName, > > userName, passWord); > > managerConnection.login(); > > } > > public boolean checkLogin() > > { > > if(managerConnection.isConnected()) > > return true; > > else > > return false; > > } > > public void getCredentials(String h, String u, String p) > > { > > userName =3D3D u; > > hostName =3D3D h; > > passWord =3D3D p; > > } > > public void logOff()throws java.io.IOException, TimeoutException > > { > > managerConnection.logoff(); > > } > > } > > > > Has anyone an idea what is wrong? > > thx in advance... > > > > henry. > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > |
From: Yelson V. <yv...@gm...> - 2006-04-01 15:51:49
|
Hi Henry The code that you show looks fine, i think the problem is a reference to a null object but in you graphical interface, as it shows AWT so i think that the problem is java, not java -asterisk. Att Yelson On 3/31/06, ast...@li... <ast...@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. MeetMe recording start event? (Jan du Toit) > 2. unable to logoff() (Henry SCHMITT) > > --__--__-- > > Message: 1 > Date: Fri, 31 Mar 2006 12:49:54 +0200 > From: Jan du Toit <jan...@de...> > To: ast...@li... > Subject: [Asterisk-java-users] MeetMe recording start event? > Reply-To: ast...@li... > > This is a multi-part message in MIME format. > --------------020806090801010502000906 > Content-Type: text/plain; charset=3DISO-8859-1; format=3Dflowed > Content-Transfer-Encoding: 7bit > > Hi. > > When starting a conference meetme with recording enabled the following > is displayed in the CLI: > > "Starting recording of MeetMe Conference 8000 into file > meetme-conf-rec-8000-1143802999.6.wav." > > Does asterisk generate a event for this? If it does why isn't their a > corrosponding event in the net.sf.asterisk.manager.event package? > > I wan't to get hold of the file name of the recording. How must I go > about this, if their isn't an event to get this information from? > > Thank you. > > Regards. > > --------------020806090801010502000906 > Content-Type: text/html; charset=3DISO-8859-1 > Content-Transfer-Encoding: 7bit > > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> > <html> > <head> > <meta content=3D"text/html;charset=3DISO-8859-1" http-equiv=3D"Content-= Type"> > </head> > <body bgcolor=3D"#ffffff" text=3D"#000000"> > Hi.<br> > <br> > When starting a conference meetme with recording enabled the following > is displayed in the CLI:<br> > <br> > "Starting recording of MeetMe Conference 8000 into file > meetme-conf-rec-8000-1143802999.6.wav."<br> > <br> > Does asterisk generate a event for this? If it does why isn't their a > corrosponding event in the net.sf.asterisk.manager.event package?<br> > <br> > I wan't to get hold of the file name of the recording. How must I go > about this, if their isn't an event to get this information from?<br> > <br> > Thank you.<br> > <br> > Regards.<br> > <font><font size=3D"-1"></font></font> > </body> > </html> > > --------------020806090801010502000906-- > > > > --__--__-- > > Message: 2 > Date: Fri, 31 Mar 2006 16:26:03 +0200 > From: "Henry SCHMITT" <hen...@gm...> > To: ast...@li... > Subject: [Asterisk-java-users] unable to logoff() > Reply-To: ast...@li... > > Hi all, > i'am new to asterisk-java (to be honest to java too), so please be clemen= t. > I am able to logon into my Asterisk server but have problem to logoff. > > #java Main > 31 mars 2006 16:11:36 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connecting to 192.168.204.223 port 5038 > 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connected via Asterisk Call Manager/1.0 > 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Successfully logged in > 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Determined Asterisk version: Asterisk 1.0 > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > at AMILogin.logOff(AMILogin.java:36) > at MainPage$1.mouseClicked(MainPage.java:50) > at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source) > at java.awt.Component.processMouseEvent(Unknown Source) > at javax.swing.JComponent.processMouseEvent(Unknown Source) > at java.awt.Component.processEvent(Unknown Source) > at java.awt.Container.processEvent(Unknown Source) > at java.awt.Component.dispatchEventImpl(Unknown Source) > at java.awt.Container.dispatchEventImpl(Unknown Source) > at java.awt.Component.dispatchEvent(Unknown Source) > at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Sour= ce=3D > ) > at java.awt.LightweightDispatcher.processMouseEvent(Unknown Sourc= e) > at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) > at java.awt.Container.dispatchEventImpl(Unknown Source) > at java.awt.Window.dispatchEventImpl(Unknown Source) > at java.awt.Component.dispatchEvent(Unknown Source) > at java.awt.EventQueue.dispatchEvent(Unknown Source) > at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown = So=3D > urce) > > at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown So= ur=3D > ce) > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > at java.awt.EventDispatchThread.run(Unknown Source) > > > here what i have... > > > 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.TimeoutException; > > public class AMILogin > { > String userName; > String hostName; > String passWord; > ManagerConnection managerConnection; > ManagerConnectionFactory factory; > > public void run() throws IOException, AuthenticationFailedException, > TimeoutException > { > factory =3D3D new ManagerConnectionFactory(); > this.managerConnection =3D3D factory.getManagerConnection(hostName, > userName, passWord); > managerConnection.login(); > } > public boolean checkLogin() > { > if(managerConnection.isConnected()) > return true; > else > return false; > } > public void getCredentials(String h, String u, String p) > { > userName =3D3D u; > hostName =3D3D h; > passWord =3D3D p; > } > public void logOff()throws java.io.IOException, TimeoutException > { > managerConnection.logoff(); > } > } > > Has anyone an idea what is wrong? > thx in advance... > > henry. > > > > --__--__-- > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > End of Asterisk-java-users Digest > |
From: Peter H. <pe...@ra...> - 2006-04-01 13:14:31
|
Dear Henry, thanks for your message! First of all, hats off - you do very well as a newcomer to Java! First of all , run() is a method used with threads. If you intend to use threads, you need to inherit your class from java.lang.Thread like so: public class AMILogin extends Thread { ... } This class would then contain the run() method. To instantiate your class and start the thread you would then do this: AMILogin myLogin = null; myLogin = new AMILogin (); myLogin.getCredentials ("192.168.10.12", "admin", "admin"); myLogin.start; // -> This calls the run() method and starts the thread! Since you used the run() method and your exception message showed traces of GUI activity while at the same time AMILogin doesn't extend java.lang.Thread, I followed two possible scenarios: a) Class AMILogin is a stand-alone class having no inheritance from java.lang.Thread. To make this work, I * I added a main() method * I changed the name of the run() method to login() * instantiated AMILogin, did a login and exited. With this approach I had no errors. b) Class AMILogin does inherit from java.lang.Thread. * I added a main() method * Program instantiated AMILogin and started the thread. * Program logged off immediately. With this approach I got a NullPointerException in the logOff method as indicated. ========================================================================= Approach a: No java.lang.Thread: ========================================================================= --------------- source code 1 start ----------------------------- package org.rww.asterisk.trials; 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.TimeoutException; public class AMILogin { String userName; String hostName; String passWord; ManagerConnection managerConnection; ManagerConnectionFactory factory; public void login() throws IOException, AuthenticationFailedException, TimeoutException { factory = new ManagerConnectionFactory(); this.managerConnection = factory.getManagerConnection(hostName, userName, passWord); managerConnection.login(); } public boolean checkLogin() { if (managerConnection.isConnected()) return true; else return false; } public void getCredentials(String h, String u, String p) { userName = u; hostName = h; passWord = p; } public void logOff() throws java.io.IOException, TimeoutException { managerConnection.logoff(); } public static void main (String [] args) { AMILogin l; try { l = new AMILogin (); l.getCredentials("192.168.10.12", "admin", "admin"); System.out.println("=======> logging in <======="); l.login(); System.out.println("\n=======> logging out <======="); l.logOff(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (AuthenticationFailedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } --------------- source code 1 end ----------------------------- The corresponding console output is: --------------- output 1 start --------------------------- =======> logging in <======= 01-Apr-2006 12:55:14 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Connecting to 192.168.10.12 port 5038 01-Apr-2006 12:55:27 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Connected via Asterisk Call Manager/1.0 01-Apr-2006 12:55:27 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Successfully logged in 01-Apr-2006 12:55:27 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Determined Asterisk version: Asterisk 1.0 =======> logging out <======= 01-Apr-2006 12:55:32 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Reached end of stream, terminating reader. 01-Apr-2006 12:55:32 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Closing socket. --------------- output 1 end --------------------------- So it worked on my machine. ========================================================================= Approach b: inherit from java.lang.Thread: ========================================================================= --------------- source code 2 start ----------------------------- package org.rww.asterisk.trials; 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.TimeoutException; public class AMILogin extends Thread { String userName; String hostName; String passWord; ManagerConnection managerConnection; ManagerConnectionFactory factory; public void run() { factory = new ManagerConnectionFactory(); try { this.managerConnection = factory.getManagerConnection(hostName, userName, passWord); managerConnection.login(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (AuthenticationFailedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public boolean checkLogin() { if (managerConnection.isConnected()) return true; else return false; } public void getCredentials(String h, String u, String p) { userName = u; hostName = h; passWord = p; } public void logOff() throws java.io.IOException, TimeoutException { managerConnection.logoff(); } public static void main (String [] args) { AMILogin l; try { l = new AMILogin (); l.getCredentials("192.168.10.12", "admin", "admin"); System.out.println("=======> logging in <======="); l.start(); System.out.println("\n=======> logging out <======="); l.logOff(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } --------------- source code 2 end ----------------------------- Lo and behold, now the corresponding console output goes like this: --------------- output 1 start --------------------------- =======> logging in <======= =======> logging out <======= Exception in thread "main" java.lang.NullPointerException at org.rww.asterisk.trials.AMILogin.logOff(AMILogin.java:70) at org.rww.asterisk.trials.AMILogin.main(AMILogin.java:85) 01-Apr-2006 13:01:44 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Connecting to 192.168.10.12 port 5038 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Connected via Asterisk Call Manager/1.0 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Successfully logged in 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Determined Asterisk version: Asterisk 1.0 --------------- output 1 end --------------------------- So, now I got the desired NullPointerException! The reason for this lies in the timing: The statements in the main() method: l = new AMILogin (); l.getCredentials("192.168.10.12", "admin", "admin"); System.out.println("=======> logging in <======="); l.start(); System.out.println("\n=======> logging out <======="); l.logOff(); make the following sequence happen: 1. Create new AMILogin 2. Get Credentials 3. Print "=======> logging in <======="; 4. Start Thread and RETURN IMMEDIATELY (!!) Now, my new AMILogin Thread starts. It 4.1. Logs into the asterisk server 4.2. Waits (!!) for the asterisk server's response At point 4.2., no ManagerConnection object exists yet as the call to this.managerConnection = factory.getManagerConnection(hostName, userName, passWord); hasn't returned and won't be for the next few seconds. Therefore the AMILogin member managerConnection remains null until the server has answered. But our main() function doesn't wait. Meanwhile it continues: 5. Print "\n=======> logging out <=======" 6. Call logoff (); And at this point, We get the NullPointerException, because in logOff() we call managerConnection.logoff(); on a non-existing object, as managerConnection is still null (since we are still waiting for the asterisk server's response). Then a few seconds later, the server does respond: 01-Apr-2006 13:01:44 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Connecting to 192.168.10.12 port 5038 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Connected via Asterisk Call Manager/1.0 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Successfully logged in 01-Apr-2006 13:01:57 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Determined Asterisk version: Asterisk 1.0 But now it's too late. What we have here is called a race condition - two thread race against each other and our application gets into a bad state. This is because the start() call is an asynchronous call - it sends the start message to the thread object and returns immediately. The opposite would be a synchronous call where the caller waits for the callee to finish. Programming wise, a call to a method / function is mostly synchronous, as the caller waits for the function to return. Some examples to illustrate this: Asynchronous call: Your boss asks you to create this report (will take four to six weeks to completion) and comes back the next day to get the result. Synchronous call: Your boss asks you to create this report (will take four to six weeks to completion) and waits for you to come back to him and then asks you for the result. In this example, the main() function is like that impatient boss - it tells your poor AMILogin object to login, but then doesn't wait and immediately wants to log out. AMILogin object shouts in protest - NullPointerException! as much as our poor employee would answer that impatient boss: "Sorry, NullReportException". Asynchronous call: You order a pizza by phone from a pizza shop. You know the pizza will come some time later and forget about the call and watch the news meanwhile. Synchronous call: You go into a pizza restaurant, sit down at a table, order a pizza and WAIT for the pizza to be finished. You certainly won't forget the order, as you can't do anything until the pizza's done. As I say, I don't know which scenario (threaded/non threaded) applies to your situation. But I hope this information helps. But there are two example applications on asterisk-java - head to http://svn.reucon.net/repos/asterisk-java-examples/trunk/ the ast-console application contains a longer text in the /doc directory explaining the application. Thanks again for your message! God bless, Peter -- dyslexics of the world - untie ! > Hi all, > i'am new to asterisk-java (to be honest to java too), so please be clement. > I am able to logon into my Asterisk server but have problem to logoff. > > #java Main > 31 mars 2006 16:11:36 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connecting to 192.168.204.223 port 5038 > 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Connected via Asterisk Call Manager/1.0 > 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Successfully logged in > 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info > INFO: Determined Asterisk version: Asterisk 1.0 > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > at AMILogin.logOff(AMILogin.java:36) > at MainPage$1.mouseClicked(MainPage.java:50) > at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source) > at java.awt.Component.processMouseEvent(Unknown Source) > at javax.swing.JComponent.processMouseEvent(Unknown Source) > at java.awt.Component.processEvent(Unknown Source) > at java.awt.Container.processEvent(Unknown Source) > at java.awt.Component.dispatchEventImpl(Unknown Source) > at java.awt.Container.dispatchEventImpl(Unknown Source) > at java.awt.Component.dispatchEvent(Unknown Source) > at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source= > ) > at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) > at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) > at java.awt.Container.dispatchEventImpl(Unknown Source) > at java.awt.Window.dispatchEventImpl(Unknown Source) > at java.awt.Component.dispatchEvent(Unknown Source) > at java.awt.EventQueue.dispatchEvent(Unknown Source) > at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown So= > urce) > > at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Sour= > ce) > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > at java.awt.EventDispatchThread.run(Unknown Source) > > > here what i have... > > > 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.TimeoutException; > > public class AMILogin > { > String userName; > String hostName; > String passWord; > ManagerConnection managerConnection; > ManagerConnectionFactory factory; > > public void run() throws IOException, AuthenticationFailedException, > TimeoutException > { > factory =3D new ManagerConnectionFactory(); > this.managerConnection =3D factory.getManagerConnection(hostName, > userName, passWord); > managerConnection.login(); > } > public boolean checkLogin() > { > if(managerConnection.isConnected()) > return true; > else > return false; > } > public void getCredentials(String h, String u, String p) > { > userName =3D u; > hostName =3D h; > passWord =3D p; > } > public void logOff()throws java.io.IOException, TimeoutException > { > managerConnection.logoff(); > } > } > > Has anyone an idea what is wrong? > thx in advance... > > henry. |
From: Henry S. <hen...@gm...> - 2006-03-31 14:26:07
|
Hi all, i'am new to asterisk-java (to be honest to java too), so please be clement. I am able to logon into my Asterisk server but have problem to logoff. #java Main 31 mars 2006 16:11:36 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Connecting to 192.168.204.223 port 5038 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Connected via Asterisk Call Manager/1.0 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Successfully logged in 31 mars 2006 16:11:37 net.sf.asterisk.util.impl.JavaLoggingLog info INFO: Determined Asterisk version: Asterisk 1.0 Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at AMILogin.logOff(AMILogin.java:36) at MainPage$1.mouseClicked(MainPage.java:50) at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source= ) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown So= urce) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Sour= ce) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) here what i have... 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.TimeoutException; public class AMILogin { String userName; String hostName; String passWord; ManagerConnection managerConnection; ManagerConnectionFactory factory; public void run() throws IOException, AuthenticationFailedException, TimeoutException { factory =3D new ManagerConnectionFactory(); this.managerConnection =3D factory.getManagerConnection(hostName, userName, passWord); managerConnection.login(); } public boolean checkLogin() { if(managerConnection.isConnected()) return true; else return false; } public void getCredentials(String h, String u, String p) { userName =3D u; hostName =3D h; passWord =3D p; } public void logOff()throws java.io.IOException, TimeoutException { managerConnection.logoff(); } } Has anyone an idea what is wrong? thx in advance... henry. |
From: Jan du T. <jan...@de...> - 2006-03-31 10:54:11
|
Hi. When starting a conference meetme with recording enabled the following is displayed in the CLI: "Starting recording of MeetMe Conference 8000 into file meetme-conf-rec-8000-1143802999.6.wav." Does asterisk generate a event for this? If it does why isn't their a corrosponding event in the net.sf.asterisk.manager.event package? I wan't to get hold of the file name of the recording. How must I go about this, if their isn't an event to get this information from? Thank you. Regards. |
From: Jason W. <jas...@be...> - 2006-03-22 13:27:15
|
The problem is that you cannot use originate to connect to an application if you want to use the default CDR. This is a documented issue. You can however, put the call into a context and call your app from the extensions in the context. Jason -----Original Message----- From: ast...@li... [mailto:ast...@li...]On Behalf Of Jan du Toit Sent: Wednesday, March 22, 2006 4:17 AM To: ast...@li... Subject: [Asterisk-java-users] Originate and CDR. Hi. I am using Originate to make outbound calls. Moreover the cdr_manager astersik module is enabled so that I can receive and handle CdrEvents via ManagerEventHandler when the call is hangedup. The problem is that the billableseconds is always zero. [CdrEvent.getBillableSeconds()] I think it has to do with the fact that the answer time field in the CDR is null [CdrEvent.getAnswerTime()]. All the other cdr fields are correct. It is as if asterisk doesn't really know when the call was answered and thus the number of billable seconds can not be established. What is causing this problem and how can it be fixed? PS. The Originate is used to connect to asterisk applications. Thus the application and data parameters are set, not the the extension and context parameters. Thanks in advance. ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Asterisk-java-users mailing list Ast...@li... https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |
From: Jan du T. <jan...@de...> - 2006-03-22 09:21:21
|
Hi. I am using Originate to make outbound calls. Moreover the cdr_manager astersik module is enabled so that I can receive and handle CdrEvents via ManagerEventHandler when the call is hangedup. The problem is that the billableseconds is always zero. [CdrEvent.getBillableSeconds()] I think it has to do with the fact that the answer time field in the CDR is null [CdrEvent.getAnswerTime()]. All the other cdr fields are correct. It is as if asterisk doesn't really know when the call was answered and thus the number of billable seconds can not be established. What is causing this problem and how can it be fixed? PS. The Originate is used to connect to asterisk applications. Thus the application and data parameters are set, not the the extension and context parameters. Thanks in advance. |
From: Cokorda R. A. J. <rak...@gm...> - 2006-03-21 02:18:34
|
Thanks Stefan, I will update the doc based on your feedback soon (btw, I just updated it -= - like 6 hours ago -- to fix some remaining typos). Best regards, Raka On 3/19/06, Stefan Reuter <sr...@re...> wrote: > > Congrats, thats really cool stuff! > I just skimmed over it and it reads very well. > > There was a question regarding the difference between actions and > commands somewhere. The concept of both is almost the same: they both > serve as command object (as in command pattern) to cause asterisk to do > something. The difference is that actions (actually imlementations of > ManagerAction) are for the Manager API and AGICommands are for AGI. > As both interfaces serve different purposes AGICommands are tied to a > specific Asterisk channel (the one connected to the AGI script) where > ManagerActions in general are independant of a specific channel. > > =3DStefan |
From: <mar...@gm...> - 2006-03-20 10:23:16
|
Hello, I am using Asterisk-java, the Manager. And I have a problem I don't know ho= w to sort it out!: Sometimes, when I send an OriginateAction my code receives an exception wit= h this message: "Timeout waiting for response to Originate" I don't know what it means as Asterisk receives the action and then dials t= o the telephone, might anybody show me what is the problem??? Thanks in advance, -- Mar=EDa |
From: Stefan R. <sr...@re...> - 2006-03-20 01:28:28
|
Hm then this looks indeed like a bug. I opened an issue for this in Jira: http://jira.reucon.org/browse/AJ-32 and will have a look at it this week. Thanks for reporting, Stefan King Ho wrote: > Below is the API doc that comes with A-J 0.3: >=20 > -----------------------------------------------------------------------= ------------------------------------------ > public class ConnectEvent > extends ManagerEvent >=20 > A ConnectEvent is triggered after successful login to the asterisk serv= er. It is a pseudo event not directly related to an asterisk generated ev= ent.=20 > -----------------------------------------------------------------------= ------------------------------------------ >=20 > When the server is restarted, I need to know if we have auto-reconnecte= d AND login successfully back to the server. If yes, I'll start another t= hread and send some actions to the server. Right now, I cannot tell with = a connectEvent is if the login is successful or not and sending actions t= o the server may be bad. >=20 > I hope this make sense. >=20 > Thanks. >=20 > King >=20 >=20 >=20 > -----Original Message----- > From: ast...@li... [mailto:asterisk-= jav...@li...] On Behalf Of Stefan Reuter > Sent: Monday, March 20, 2006 1:13 AM > To: ast...@li... > Subject: Re: [Asterisk-java-users] About the connectEvent >=20 > in this case it does what the api docs say (being triggered when > connected to asterisk, not after authentication succeeded), right? >=20 > are you in need of an event that is triggered upon successful > authentication? if yes, why? (login() won't return until authentication= > either succeeded or failed, anyway) >=20 > =3DStefan >=20 >=20 > King Ho wrote: >=20 >>Hi, >> >>=20 >> >>I think my description is incorrect!! >> >>=20 >> >>I think the connectEvent is sent every time, including the first attemp= t, after a login(), whether it is successful or not. >> >>=20 >> >>Sorry about the confusion! >> >>=20 >> >>King >> >>=20 >> >> _____ =20 >> >>From: ast...@li... [mailto:asterisk-= jav...@li...] On Behalf Of King Ho >>Sent: Monday, March 20, 2006 12:21 AM >>To: ast...@li... >>Subject: [Asterisk-java-users] About the connectEvent >> >>=20 >> >>=20 >> >>Hi, >> >>=20 >> >>According to the api doc, the connectEvent should be sent after success= ful login to the asterisk server. >> >>=20 >> >>However, it seems that it will be sent whenever the driver is reconnect= ed to the asterisk server. This may be caused by an initial login=20 >> >>failure and the program tries to login again. In my program I have some= thing like the following: >> >>=20 >> >> boolean authenticated =3D false; >> >> while (!authenticated) { >> >> try { >> >> ManagerConnectionFactory factory =3D new ManagerCon= nectionFactory( >> >> address, port, login, password); >> >> managerConnection.addEventHandler(this); >> >> managerConnection =3D factory.createManagerConnecti= on(); >> >> managerConnection.login(); >> >> authenticated =3D true; >> >> } catch (IOException e) { >> >> Thread.sleep(5000); >> >> } catch (TimeoutException e) { >> >> Thread.sleep(5000); >> >> } catch (AuthenticationFailedException e) { >> >> Thread.sleep(5000); >> >> } >> >> } >> >>=20 >> >>If I have the login name or password incorrect, the connectEvent will s= tart coming in starting from the second >> >>login attempt (no connectEvent is received during the first login attem= pt). >> >>=20 >> >>I think receiving the connectEvent before successfully login to the ast= erisk server is kind of useless as nothing can >> >>be done until login is successful. >> >>=20 >> >>Thanks. >> >>=20 >> >>Best Regards, >> >>=20 >> >>King >> >> >=20 >=20 >=20 --=20 reuter network consulting Neusser Str. 110 50760 K=C3=B6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |
From: Stefan R. <sr...@re...> - 2006-03-20 01:27:15
|
Hi Cameron, [...] > results in: > SEVERE: Unable to convert value '5060' of property 'ipport' on class > net.sf.asterisk.manager.event.PeerEntryEvent to required type int [...] > Is this something I am doing wrong in my code, or a problem with the > framework?=20 This is a bug in 0.2. Either use http://null.reucon.net/~srt/asterisk-java-0.2-fix1.jar or upgrade to 0.3-SNAPSHOT (http://asteriskjava.org/0.3-SNAPSHOT) > I also ran into a "no setter for the dnd field" when > performing the ZapShowChannelsAction. this is due to 0.2 not yet supporting all fields of Asterisk 1.2.4. As long as you dont need that field you can ignore the message. =3DStefan --=20 reuter network consulting Neusser Str. 110 50760 K=F6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |
From: Cameron S. <ca...@sc...> - 2006-03-20 01:18:57
|
Hi, I just downloaded asterisk-java 0.2 and went through the HeloWorld tutorials without hassle. I was playing around with the manager interface, and ran into an issue with a couple of the event classes. I am using sun's java 1.5 (same results with 1.4.2) and asterisk 1.2.4. Changing the HelloEvent to do: managerConnection.sendAction(new SIPPeersAction()); (I also added some code to print our the IP and port from the PeerEntryEvent) results in: SEVERE: Unable to convert value '5060' of property 'ipport' on class net.sf.asterisk.manager.event.PeerEntryEvent to required type int java.lang.NoSuchMethodException: int.<init>(java.lang.String) at java.lang.Class.getConstructor0(Class.java:1937) at java.lang.Class.getConstructor(Class.java:1027) at net.sf.asterisk.manager.impl.EventBuilderImpl.setAttributes(EventBuilderImpl.java:368) at net.sf.asterisk.manager.impl.EventBuilderImpl.buildEvent(EventBuilderImpl.java:288) at net.sf.asterisk.manager.impl.ManagerReaderImpl.buildEvent(ManagerReaderImpl.java:309) at net.sf.asterisk.manager.impl.ManagerReaderImpl.run(ManagerReaderImpl.java:233) at java.lang.Thread.run(Thread.java:534) Got Event: net.sf.asterisk.manager.event.PeerEntryEvent: dateReceived=Sun Mar 19 18:14:30 GMT-07:00 2006; systemHashcode=3317565 IP: 10.0.23.40 Port: 0 Is this something I am doing wrong in my code, or a problem with the framework? I also ran into a "no setter for the dnd field" when performing the ZapShowChannelsAction. Cam |
From: King H. <kin...@ne...> - 2006-03-19 19:41:16
|
Below is the API doc that comes with A-J 0.3: -------------------------------------------------------------------------= ---------------------------------------- public class ConnectEvent extends ManagerEvent A ConnectEvent is triggered after successful login to the asterisk = server. It is a pseudo event not directly related to an asterisk = generated event.=20 -------------------------------------------------------------------------= ---------------------------------------- When the server is restarted, I need to know if we have auto-reconnected = AND login successfully back to the server. If yes, I'll start another = thread and send some actions to the server. Right now, I cannot tell = with a connectEvent is if the login is successful or not and sending = actions to the server may be bad. I hope this make sense. Thanks. King -----Original Message----- From: ast...@li... = [mailto:ast...@li...] On Behalf Of = Stefan Reuter Sent: Monday, March 20, 2006 1:13 AM To: ast...@li... Subject: Re: [Asterisk-java-users] About the connectEvent in this case it does what the api docs say (being triggered when connected to asterisk, not after authentication succeeded), right? are you in need of an event that is triggered upon successful authentication? if yes, why? (login() won't return until authentication either succeeded or failed, anyway) =3DStefan King Ho wrote: > Hi, >=20 > =20 >=20 > I think my description is incorrect!! >=20 > =20 >=20 > I think the connectEvent is sent every time, including the first = attempt, after a login(), whether it is successful or not. >=20 > =20 >=20 > Sorry about the confusion! >=20 > =20 >=20 > King >=20 > =20 >=20 > _____ =20 >=20 > From: ast...@li... = [mailto:ast...@li...] On Behalf Of = King Ho > Sent: Monday, March 20, 2006 12:21 AM > To: ast...@li... > Subject: [Asterisk-java-users] About the connectEvent >=20 > =20 >=20 > =20 >=20 > Hi, >=20 > =20 >=20 > According to the api doc, the connectEvent should be sent after = successful login to the asterisk server. >=20 > =20 >=20 > However, it seems that it will be sent whenever the driver is = reconnected to the asterisk server. This may be caused by an initial = login=20 >=20 > failure and the program tries to login again. In my program I have = something like the following: >=20 > =20 >=20 > boolean authenticated =3D false; >=20 > while (!authenticated) { >=20 > try { >=20 > ManagerConnectionFactory factory =3D new = ManagerConnectionFactory( >=20 > address, port, login, password); >=20 > managerConnection.addEventHandler(this); >=20 > managerConnection =3D = factory.createManagerConnection(); >=20 > managerConnection.login(); >=20 > authenticated =3D true; >=20 > } catch (IOException e) { >=20 > Thread.sleep(5000); >=20 > } catch (TimeoutException e) { >=20 > Thread.sleep(5000); >=20 > } catch (AuthenticationFailedException e) { >=20 > Thread.sleep(5000); >=20 > } >=20 > } >=20 > =20 >=20 > If I have the login name or password incorrect, the connectEvent will = start coming in starting from the second >=20 > login attempt (no connectEvent is received during the first login = attempt). >=20 > =20 >=20 > I think receiving the connectEvent before successfully login to the = asterisk server is kind of useless as nothing can >=20 > be done until login is successful. >=20 > =20 >=20 > Thanks. >=20 > =20 >=20 > Best Regards, >=20 > =20 >=20 > King >=20 >=20 --=20 reuter network consulting Neusser Str. 110 50760 K=C3=B6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |
From: Stefan R. <sr...@re...> - 2006-03-19 17:13:12
|
in this case it does what the api docs say (being triggered when connected to asterisk, not after authentication succeeded), right? are you in need of an event that is triggered upon successful authentication? if yes, why? (login() won't return until authentication either succeeded or failed, anyway) =3DStefan King Ho wrote: > Hi, >=20 > =20 >=20 > I think my description is incorrect!! >=20 > =20 >=20 > I think the connectEvent is sent every time, including the first attemp= t, after a login(), whether it is successful or not. >=20 > =20 >=20 > Sorry about the confusion! >=20 > =20 >=20 > King >=20 > =20 >=20 > _____ =20 >=20 > From: ast...@li... [mailto:asterisk-= jav...@li...] On Behalf Of King Ho > Sent: Monday, March 20, 2006 12:21 AM > To: ast...@li... > Subject: [Asterisk-java-users] About the connectEvent >=20 > =20 >=20 > =20 >=20 > Hi, >=20 > =20 >=20 > According to the api doc, the connectEvent should be sent after success= ful login to the asterisk server. >=20 > =20 >=20 > However, it seems that it will be sent whenever the driver is reconnect= ed to the asterisk server. This may be caused by an initial login=20 >=20 > failure and the program tries to login again. In my program I have some= thing like the following: >=20 > =20 >=20 > boolean authenticated =3D false; >=20 > while (!authenticated) { >=20 > try { >=20 > ManagerConnectionFactory factory =3D new ManagerCon= nectionFactory( >=20 > address, port, login, password); >=20 > managerConnection.addEventHandler(this); >=20 > managerConnection =3D factory.createManagerConnecti= on(); >=20 > managerConnection.login(); >=20 > authenticated =3D true; >=20 > } catch (IOException e) { >=20 > Thread.sleep(5000); >=20 > } catch (TimeoutException e) { >=20 > Thread.sleep(5000); >=20 > } catch (AuthenticationFailedException e) { >=20 > Thread.sleep(5000); >=20 > } >=20 > } >=20 > =20 >=20 > If I have the login name or password incorrect, the connectEvent will s= tart coming in starting from the second >=20 > login attempt (no connectEvent is received during the first login attem= pt). >=20 > =20 >=20 > I think receiving the connectEvent before successfully login to the ast= erisk server is kind of useless as nothing can >=20 > be done until login is successful. >=20 > =20 >=20 > Thanks. >=20 > =20 >=20 > Best Regards, >=20 > =20 >=20 > King >=20 >=20 --=20 reuter network consulting Neusser Str. 110 50760 K=C3=B6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |
From: King H. <kin...@ne...> - 2006-03-19 16:44:30
|
Hi, =20 I think my description is incorrect!! =20 I think the connectEvent is sent every time, including the first = attempt, after a login(), whether it is successful or not. =20 Sorry about the confusion! =20 King =20 _____ =20 From: ast...@li... = [mailto:ast...@li...] On Behalf Of = King Ho Sent: Monday, March 20, 2006 12:21 AM To: ast...@li... Subject: [Asterisk-java-users] About the connectEvent =20 =20 Hi, =20 According to the api doc, the connectEvent should be sent after = successful login to the asterisk server. =20 However, it seems that it will be sent whenever the driver is = reconnected to the asterisk server. This may be caused by an initial = login=20 failure and the program tries to login again. In my program I have = something like the following: =20 boolean authenticated =3D false; while (!authenticated) { try { ManagerConnectionFactory factory =3D new = ManagerConnectionFactory( address, port, login, password); managerConnection.addEventHandler(this); managerConnection =3D = factory.createManagerConnection(); managerConnection.login(); authenticated =3D true; } catch (IOException e) { Thread.sleep(5000); } catch (TimeoutException e) { Thread.sleep(5000); } catch (AuthenticationFailedException e) { Thread.sleep(5000); } } =20 If I have the login name or password incorrect, the connectEvent will = start coming in starting from the second login attempt (no connectEvent is received during the first login = attempt). =20 I think receiving the connectEvent before successfully login to the = asterisk server is kind of useless as nothing can be done until login is successful. =20 Thanks. =20 Best Regards, =20 King |
From: King H. <kin...@ne...> - 2006-03-19 16:21:31
|
=20 Hi, =20 According to the api doc, the connectEvent should be sent after = successful login to the asterisk server. =20 However, it seems that it will be sent whenever the driver is = reconnected to the asterisk server. This may be caused by an initial = login=20 failure and the program tries to login again. In my program I have = something like the following: =20 boolean authenticated =3D false; while (!authenticated) { try { ManagerConnectionFactory factory =3D new = ManagerConnectionFactory( address, port, login, password); managerConnection.addEventHandler(this); managerConnection =3D = factory.createManagerConnection(); managerConnection.login(); authenticated =3D true; } catch (IOException e) { Thread.sleep(5000); } catch (TimeoutException e) { Thread.sleep(5000); } catch (AuthenticationFailedException e) { Thread.sleep(5000); } } =20 If I have the login name or password incorrect, the connectEvent will = start coming in starting from the second login attempt (no connectEvent is received during the first login = attempt). =20 I think receiving the connectEvent before successfully login to the = asterisk server is kind of useless as nothing can be done until login is successful. =20 Thanks. =20 Best Regards, =20 King |
From: Stefan R. <sr...@re...> - 2006-03-19 10:37:48
|
> To be honest, I don't quite understand the purpose of having a public > and an internal action id. The internal should be enough, providing tha= t > it can be used for matching subsequent events. There are two reasons for that: 1. I don't like A-J silently modifying user objects such as actions when not strictly necessary. 2. The user's code must know the action id before sendAction(..) returns. If it doesn't a custom event- or responselistener can only be informed about the action id after the action has been sent to asterisk. In this case there is a chance that the user's code misses the event or response (if it is received before the action id was passed to the listener). With the user provided action id the listener can be informed before the action is sent and there is no way to miss anything. > It probably doesn't do any harm, but I think some additional > documentation is required on the method to explain its use. Yeah I will update the docs for set/getActionId. > Having said that I still suspect that there is something dodgy with > sendEventGeneratingAction as I've had OriginateCall hang on me. > I will have a try at reproducing the problem when I have a moment. Mayb= e > now that I understand how to use the code base the problem may disappea= r :) Ok, if you find a bug i am happy to fix it :) Based upon your experience with moving AsterFax to 0.3 you think 0.3 is ready for a release candidate? =3DStefan --=20 reuter network consulting Neusser Str. 110 50760 K=F6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |
From: Brett S. <bs...@no...> - 2006-03-19 10:04:51
|
Mis-understanding on my part. OK, I reverted my code changes to the standard 0.3 code base and set the action id explicitly. I had got so caught up in the detail that I didn't release that I could set and retrieve the action id. To be honest, I don't quite understand the purpose of having a public and an internal action id. The internal should be enough, providing that it can be used for matching subsequent events. The only purpose I can image for an externally settable action id is to pass 'User Data' to the subsequent events and this is probably a fairly marginal use case. It probably doesn't do any harm, but I think some additional documentation is required on the method to explain its use. I went in assuming that setActionId was really a private method (yes I know its defined as a public method, but that sometimes just means its users are in a different package) and that getActionId would always return a good value. When it returned null I assumed that there was a bug and went about fixing it :<. So I'm now using it as intended and all works fine. Having said that I still suspect that there is something dodgy with sendEventGeneratingAction as I've had OriginateCall hang on me. I will have a try at reproducing the problem when I have a moment. Maybe now that I understand how to use the code base the problem may disappear :) Regards, Brett. |
From: Stefan R. <sr...@re...> - 2006-03-19 00:30:15
|
Congrats, thats really cool stuff! I just skimmed over it and it reads very well. There was a question regarding the difference between actions and commands somewhere. The concept of both is almost the same: they both serve as command object (as in command pattern) to cause asterisk to do something. The difference is that actions (actually imlementations of ManagerAction) are for the Manager API and AGICommands are for AGI. As both interfaces serve different purposes AGICommands are tied to a specific Asterisk channel (the one connected to the AGI script) where ManagerActions in general are independant of a specific channel. =3DStefan Cokorda Raka Angga Jananuraga wrote: > Hi, >=20 > I would like to share the booklet I've written. It-s about developing > telephony application on top of Asterisk, using other open source stuff= s > like Asterisk-Java library, NIST-SIP library, and SIPp for testing. >=20 > I make the files -- a PDF and a targz that contains the source code -- > available on: http://www.simitel.com/resources/booklet1 >=20 > I hope I can gather some feedbacks from the readers, to find out the de= fects > in my writings. Please let me know if there is anything inaccurate / > completely stupid. I'd also like to know the effectivenes of the bookle= t in > making someone who has never got in touch with Asterik and telephony in= > general -- but can do Java -- to understand the things explained in the= > booklet. Suggesstions and critics in the style of writing, choice of wo= rds, > and format are also welcome. Basically, anything that could contribute = to > the improvement :) >=20 > Ok, that's all. Enjoy. >=20 > Best regards, > Raka -- http://www.jroller.com/page/donraka >=20 --=20 reuter network consulting Neusser Str. 110 50760 K=F6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |
From: Cokorda R. A. J. <rak...@gm...> - 2006-03-18 00:25:46
|
Hi, I would like to share the booklet I've written. It-s about developing telephony application on top of Asterisk, using other open source stuffs like Asterisk-Java library, NIST-SIP library, and SIPp for testing. I make the files -- a PDF and a targz that contains the source code -- available on: http://www.simitel.com/resources/booklet1 I hope I can gather some feedbacks from the readers, to find out the defect= s in my writings. Please let me know if there is anything inaccurate / completely stupid. I'd also like to know the effectivenes of the booklet in making someone who has never got in touch with Asterik and telephony in general -- but can do Java -- to understand the things explained in the booklet. Suggesstions and critics in the style of writing, choice of words, and format are also welcome. Basically, anything that could contribute to the improvement :) Ok, that's all. Enjoy. Best regards, Raka -- http://www.jroller.com/page/donraka |
From: Tony M. <to...@am...> - 2006-03-17 12:08:27
|
I think what you would probably want is for all errors to be logged and = then you can configure a log4j appender to output errors to the console if = that is where you want them to go. Normally you wouldn't want this sort of library, asterisk-java, to = output anything to System.out. =20 -----Original Message----- .... The class needed to perform string concatenation couldn't be found at runtime and therefore the DefaultAGIServer just hung, and then gave a = severe error on subsequent requests. Is there a way to simply change the way = this server works so that it would give detailed error information to the = screen when this type of thing happens? would this be a worthwhile change? I = had the code in the agi in try-catch blocks, with a system.out of the = exception, but didn't see this on the screen. running the program in main I was = able to see the problem, so I'll do this quicker next time. perhaps this was = more about honing my debugging technique than anything else! :) Thanks again Stefan for your hard work on Asterisk-Java. -----Original Message----- From: ast...@li... [mailto:ast...@li...]On Behalf Of Stefan Reuter Sent: Wednesday, March 08, 2006 5:26 PM To: ast...@li... Subject: Re: [Asterisk-java-users] Is this a bug? Jason Wolfe wrote: > as it turns out... I can't concatenate String variables in java on = this > machine!? (weird I know) This thing in a main runs on my test and > devolepment machines fine, then get's to the production machine as a service > and fails... even in a main) what JDK are you running on that machine? a sun one or some of the "free" ones like kaffee that sometimes come shipped with linux distros? try a java -version You probably want to make sure you are actually running a recent sun (or bea jrockit) jdk there. =3DStefan -- reuter network consulting Neusser Str. 110 50760 K=F6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting = language that extends applications into web and mobile media. Attend the live = webcast and join the prime developer group breaking into this new coding = territory! http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=3D= 121642 _______________________________________________ Asterisk-java-users mailing list Ast...@li... https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |
From: Stefan R. <sr...@re...> - 2006-03-17 12:03:53
|
Jason Wolfe wrote: > The class needed to perform string concatenation couldn't be found at > runtime and therefore the DefaultAGIServer just hung, and then gave a s= evere > error on subsequent requests. Is there a way to simply change the way t= his > server works so that it would give detailed error information to the sc= reen > when this type of thing happens? would this be a worthwhile change?=20 If I should consider a change (e.g. better logging) I need more information about the cause, i.e. which class was not available and where did DefaultAGIServer hang? Did you enable log4j logging and checked that this error was not reported in A-J's logs? silently failing without either a log entry or an exception being thrown is bad and should be fixed. =3DStefan --=20 reuter network consulting Neusser Str. 110 50760 K=F6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... |
From: Jason W. <jas...@be...> - 2006-03-17 11:53:06
|
I finally found the problem listed below and wanted to communicate it because perhaps it will be a help to others. I had reset the classpath on the machine, and it was not correct(typo). I was able to run all types of simple java programs so I thought that this couldn't be the problem. However, I was not able to concatenate strings. Someone on the groups told me that the chance of the program failing on that line (where the concatenation was) was 0%. Saying the chance of anything failing is 0% is probably never appropriate, as there is always a possibility, and in this case, was the direct key to the problem. The class needed to perform string concatenation couldn't be found at runtime and therefore the DefaultAGIServer just hung, and then gave a severe error on subsequent requests. Is there a way to simply change the way this server works so that it would give detailed error information to the screen when this type of thing happens? would this be a worthwhile change? I had the code in the agi in try-catch blocks, with a system.out of the exception, but didn't see this on the screen. running the program in main I was able to see the problem, so I'll do this quicker next time. perhaps this was more about honing my debugging technique than anything else! :) Thanks again Stefan for your hard work on Asterisk-Java. -----Original Message----- From: ast...@li... [mailto:ast...@li...]On Behalf Of Stefan Reuter Sent: Wednesday, March 08, 2006 5:26 PM To: ast...@li... Subject: Re: [Asterisk-java-users] Is this a bug? Jason Wolfe wrote: > as it turns out... I can't concatenate String variables in java on this > machine!? (weird I know) This thing in a main runs on my test and > devolepment machines fine, then get's to the production machine as a service > and fails... even in a main) what JDK are you running on that machine? a sun one or some of the "free" ones like kaffee that sometimes come shipped with linux distros? try a java -version You probably want to make sure you are actually running a recent sun (or bea jrockit) jdk there. =Stefan -- reuter network consulting Neusser Str. 110 50760 Köln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |
From: Stefan R. <sr...@re...> - 2006-03-17 03:35:32
|
P.S. can you try the new method AsteriskChannel originate(String channel, String context, String exten, int priority, long timeout) in A-J 0.3's DefaultAsteriskManager and verify if the problem is present there as well? The approach I choose there is a totally different from the "old" one. What happens is that we only retrieve the uniqueId from the OriginateSuccessEvent and then lookup the channel. Channel creation and updating is done only by following ChannelEvents, i.e. NewChannelEvent, NewExtenEvent, HangupEvent and so on. That approach should even work with hangups being received before the OriginateSuccessEvent. =3DStefan --=20 reuter network consulting Neusser Str. 110 50760 K=F6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |
From: Stefan R. <sr...@re...> - 2006-03-17 03:25:32
|
Brett Sutton wrote: > I'm guessing that the problem revolves around on how > sendEventGeneratingAction identifies a matching event. I'm guessing tha= t > it is using the channel name to do a match (given that it doesn't have = a > uniqueid to match on). sendEventGeneratingAction identifies matching events by using the internal action id, so there is no dependency on any other data like unique id, channel name or whatever. Let me clarify how that action id stuff currently works: asume you send an action with actionId =3D "MyActionId-1" (lets call this= user provided actionId) via sendEvent() sendEvents (in fact it is ActionWriter that is used by sendEvent, but that doesnt matter here) adds the "internalActionId", i.e. sth like "6301159_3". So what is sent to asterisk is 6301159_3#MyActionId-1. when a response or response event is received the internalActionId is retrieved and removed, so the actionId that your app receives is "MyActionId-1". Any internal matching is based on the internalActionId. If your application also needs some matching logic that should probably be done via the user provided action id. What your patch seems to do is to use the internalActionId automatically as userprovided action id as well. So what we sent to asterisk is finally something like 6301159_3#6301159_3 with the original action id provided by the user being trashed. Is this correct? > If you send an originate such as Zap/g0 then it > affectively hangs. I'm also concerned with timing issues (which could > also be the source of the hang). I'm not certain but I have a suspicion= > that in unusual circumstance other events (such as a hangup) could occu= r > before the response event. > If this occurs then its not possible to match the hangup to the > originate (and them my program hangs :<). >=20 > The scenario is this: > Register hangup event handler > Send originate - call established > Call instantly drops > Hangup event generated > Event Generation Action sent - oops too late, line has already hungup. >=20 > For this to work reliably the send event generation call would need to > be made before the originate is sent (I suspect I have seen the Call > class fails because of this scenario). ok i think see the issue here. DefaultAsteriskManager is not capable to handle this situation right now. So what do you do in this case? you can save the action id of the originate and but you have no way to match it with the hangup event as the hangup event only includes the uniqueId and that one is only known after the originate event has been received. so you have to store hangup events somewhere and upon receiving the originate event check that there was no hangup event before. right? > Is it possible to sent the event generation call before the originate? i dont understand that one. > I've been running ngrep and it seems to support my arguments. so your ngrep output indicates that there are hangups before originate events? then this is a bug in DefaultAsteriskManager. > The action id method I've implemented resolve all of these issues and > IMHO is much easier to use. do you think this works with using a user provided action id or do we really need to alter the A-J code for this to work. I have a bit of a problem with just overwriting the action id set by the user as this users from doing their own matching. That's why my approach was to hide all that internalActionId stuff from users. =3DStefan --=20 reuter network consulting Neusser Str. 110 50760 K=F6ln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: sr...@re... Jabber: sr...@ja... |