Thread: [Asterisk-java-users] AGI script hangs on string concatenation...
Brought to you by:
srt
From: Jason W. <ja...@cl...> - 2006-03-02 20:03:15
|
Stefan, When I found out that newline is sufficient for adding multiple mappings to fastagi-mapping.properties, I realized that the problem was deeper. I have the following code that works right up to the last line, where I concatenate a string 'etext' with the += operator. **************************************************************************** ************** **************************************************************************** **************** import net.sf.asterisk.fastagi.AGIChannel; import net.sf.asterisk.fastagi.AGIException; import net.sf.asterisk.fastagi.AGIRequest; import net.sf.asterisk.fastagi.BaseAGIScript; import java.util.*; import javax.mail.*; import javax.mail.internet.*; public class imail extends BaseAGIScript { public void service(AGIRequest request, AGIChannel channel) throws AGIException { System.out.println("Starting Insurance Email AGI"); String itype, year, make, model, areacode; String dmail,etext,email1,email2,email3; email1 = "jason"; email2 = "clickforacall"; email3 = "com"; itype = "error"; year = "error"; make = "error"; model = "error"; areacode = "error"; try { email1 = request.getParameter("email1"); email2 = request.getParameter("email2"); email3 = request.getParameter("email3"); itype = request.getParameter("itype"); year = request.getParameter("year"); make = request.getParameter("make"); model = request.getParameter("model"); areacode = request.getParameter("areacode"); System.out.println("Parameters accepted"); } catch (Exception e) { System.out.println(e); } etext = "Hello,\n"; etext += "The Customer has entered the following information at the time of call:\n\n"; //HANGS ON THIS LINE //I cant make it past the line above my concatenation. /* etext += "Insurance Type: " + itype + "\n"; etext += "Auto Year: " + year + "\n"; etext += "Auto Make: " + make + "\n"; etext += "Auto Model: " + model + "\n"; etext += "Customer Area Code: " + areacode + "\n"; System.out.println("text set"); Properties props = new Properties(); props.put("mail.smtp.host", "mail.clickforacall.com"); Session s = Session.getInstance(props,null); MimeMessage message = new MimeMessage(s); try{ InternetAddress from = new InternetAddress("Quo...@cl..."); message.setFrom(from); String toAddress = request.getParameter("to"); InternetAddress to = new InternetAddress(email1 + "@" + email2 + "." + email3); message.addRecipient(Message.RecipientType.TO, to); }catch(Exception e){ System.out.println("EXCEPTION_1:" + e); } String subject = "Customer Quote Data"; try{ message.setSubject(subject); message.setText(etext); Transport.send(message); }catch(Exception e){ System.out.println("EXCEPTION_2:" + e); } //get some variables and send the email... */ } } **************************************************************************** ******* **************************************************************************** ******* This was working for awhile, and then suddenly stoped. Any ideas why this would cause the script to hang? It leaves the last message on the screen >>> INFO: Received Connection <<< and that's it. If there are additional log files that would help, could you tell me where to find them? Thanks, Jason |
From: Brett S. <bs...@no...> - 2006-03-02 20:14:48
|
The chances of your applications hanging on that actual line are about zero. I do however note that the line has two \n's. I would strong suggest testing your service method as a standalone application (just re-write it as a main()). Regards, Brett. Jason Wolfe wrote: > Stefan, > > When I found out that newline is sufficient for adding multiple mappings to > fastagi-mapping.properties, I realized that the problem was deeper. I have > the following code that works right up to the last line, where I concatenate > a string 'etext' with the += operator. > > **************************************************************************** > ************** > **************************************************************************** > **************** > > import net.sf.asterisk.fastagi.AGIChannel; > import net.sf.asterisk.fastagi.AGIException; > import net.sf.asterisk.fastagi.AGIRequest; > import net.sf.asterisk.fastagi.BaseAGIScript; > > import java.util.*; > import javax.mail.*; > import javax.mail.internet.*; > > public class imail extends BaseAGIScript { > public void service(AGIRequest request, AGIChannel channel) throws > AGIException > { > System.out.println("Starting Insurance Email AGI"); > String itype, year, make, model, areacode; > String dmail,etext,email1,email2,email3; > > email1 = "jason"; > email2 = "clickforacall"; > email3 = "com"; > itype = "error"; > year = "error"; > make = "error"; > model = "error"; > areacode = "error"; > > try { > email1 = request.getParameter("email1"); > email2 = request.getParameter("email2"); > email3 = request.getParameter("email3"); > > itype = request.getParameter("itype"); > year = request.getParameter("year"); > make = request.getParameter("make"); > model = request.getParameter("model"); > areacode = request.getParameter("areacode"); > System.out.println("Parameters accepted"); > } catch (Exception e) { > System.out.println(e); > } > etext = "Hello,\n"; > etext += "The Customer has entered the following information at the > time of call:\n\n"; //HANGS ON THIS LINE > > > //I cant make it past the line above my concatenation. > > > > > > > > > > > /* > etext += "Insurance Type: " + itype + "\n"; > etext += "Auto Year: " + year + "\n"; > etext += "Auto Make: " + make + "\n"; > etext += "Auto Model: " + model + "\n"; > etext += "Customer Area Code: " + areacode + "\n"; > System.out.println("text set"); > > > Properties props = new Properties(); > props.put("mail.smtp.host", "mail.clickforacall.com"); > Session s = Session.getInstance(props,null); > > MimeMessage message = new MimeMessage(s); > > try{ > > InternetAddress from = new > InternetAddress("Quo...@cl..."); > message.setFrom(from); > String toAddress = request.getParameter("to"); > InternetAddress to = new InternetAddress(email1 + "@" + email2 + "." + > email3); > message.addRecipient(Message.RecipientType.TO, to); > }catch(Exception e){ > System.out.println("EXCEPTION_1:" + e); > } > > > > > > String subject = "Customer Quote Data"; > > try{ > > message.setSubject(subject); > message.setText(etext); > > Transport.send(message); > }catch(Exception e){ > System.out.println("EXCEPTION_2:" + e); > } > > //get some variables and send the email... > > > */ > } > > } > > **************************************************************************** > ******* > **************************************************************************** > ******* > > > This was working for awhile, and then suddenly stoped. Any ideas why this > would cause the script to hang? > > It leaves the last message on the screen >>> INFO: Received Connection <<< > and that's it. > > If there are additional log files that would help, could you tell me where > to find them? > > Thanks, > Jason > > > > ------------------------------------------------------- > 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: King H. <kin...@ne...> - 2006-03-04 06:14:00
|
Hi, I've found a problem with the ResourceBundleMappingStrategy when after = the server=20 startup and several AGI requests comes in at the same time, then it is = possible that=20 other than the first request, the other may failed with the 'No script = configured for URL'=20 error.=20 This is because the first request will do a 'loadResourceBundle' and set = mappings =3D new HashMap() The other request will see that 'mapping' is not null and will proceed = to do a lookup. If=20 'loadResourceBundle' has not finished reading the mapping the server = will give the=20 'No script configured for URL' error. Setting 'mappings' at the end of 'loadResourceBundle' will also not work = as the=20 other requests will each do a 'loadResourceBundle'. I think one way to = solve this=20 problem is to do 'loadResourceBundle' in the = 'ResourceBundleMappingStrategy' constructor.=20 Thanks. Best Regards, King Ho |
From: Stefan R. <sr...@re...> - 2006-03-04 09:19:25
Attachments:
signature.asc
|
Hi, thanks for reporting this bug. I fixed it for 0.3 by putting loadResourceBundle() inside a synchronized block. Moving it into the constructor would also have worked but then I also had to change setResourceBundleName(). Do you need a fix for 0.2 or is it ok for you to switch to a 0.3 snapshot= ? =3DStefan --=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-04 10:35:40
|
I'll try to download 0.3 snapshot from the cvs archive later. The gz = version that I just download don't have the fix in yet.=20 However, after thinking about it, using a synchronized block may be an = overkill for 'determineScript' as there will be a slight performance = hit. Unless you are planning on allowing the reloading of a new mapping = after the first one is loaded. Furthermore, as there is a constructor = that allows the specification of the bundle name, I don't think there is = really a need for setResourceBundleName(). Since I don't use the = setResourceBundleName() myself, I am biased ;) King -----Original Message----- From: ast...@li... = [mailto:ast...@li...] On Behalf Of = Stefan Reuter Sent: Saturday, March 04, 2006 5:19 PM To: ast...@li... Subject: Re: [Asterisk-java-users] Timing issue with = ResourceBundleMappingStrategy Hi, thanks for reporting this bug. I fixed it for 0.3 by putting loadResourceBundle() inside a synchronized block. Moving it into the constructor would also have worked but then I also had to change setResourceBundleName(). Do you need a fix for 0.2 or is it ok for you to switch to a 0.3 = snapshot? =3DStefan --=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-04 12:40:25
Attachments:
signature.asc
|
0.3 is currently available only from svn at http://svn.reucon.net/repos/asterisk-java/trunk you are right that the synchronized block might be a small performance hit but I dont think it has any real world impact as it is (a) only passed once per AGIRequest and (b) is really small once mappings has been initialized (only a check for null). > Unless you are planning on allowing the reloading of a new mapping > after the first one is loaded. Furthermore, as there is a constructor > that allows the specification of the bundle name, I don't think there > is really a need for setResourceBundleName(). > Since I don't use the setResourceBundleName() myself, I am biased ;) I am using setResourceBundleName() with setter based dependency injection using the spring framework. In this case spring creates the instance using its default constructor and later calls its setters for each specified property. =3DStefan --=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: Tony M. <to...@am...> - 2006-03-04 13:23:19
|
Stefan, I got my earlier versions of asterisk-java from sourceforge CVS. Is the = new repository going to be the subversion reucon site? Tony -----Original Message----- From: ast...@li... [mailto:ast...@li...] On Behalf Of = Stefan Reuter Sent: Saturday, March 04, 2006 1:40 PM To: ast...@li... Subject: Re: [Asterisk-java-users] Timing issue with ResourceBundleMappingStrategy 0.3 is currently available only from svn at http://svn.reucon.net/repos/asterisk-java/trunk you are right that the synchronized block might be a small performance hit but I dont think it has any real world impact as it is (a) only passed once per AGIRequest and (b) is really small once mappings has been initialized (only a check for null). > Unless you are planning on allowing the reloading of a new mapping > after the first one is loaded. Furthermore, as there is a constructor > that allows the specification of the bundle name, I don't think there > is really a need for setResourceBundleName(). > Since I don't use the setResourceBundleName() myself, I am biased ;) I am using setResourceBundleName() with setter based dependency injection using the spring framework. In this case spring creates the instance using its default constructor and later calls its setters for each specified property. =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-04 13:46:03
Attachments:
signature.asc
|
Tony, yes I moved away from sourceforge's CVS due to several reasons: (a) Delay between developer CVS (master) and public CVS (replication) (b) Huge delay for changes to appear in fisheye (usually 24h) (c) write access to CVS was painful slow most of the time even completly unavailable from time to time (d) CVS sucks compared to SVN ;) (ok sf offeres experimental SVN, but with (a)-(c) I choose not to give it a try) (a) often resulted in problems with changes not being immediately available for testing by users and (b) rendered fisheye rather useless. Therefore the new source repository is available at http://svn.reucon.net/ with Asterisk-Java's trunk at http://svn.reucon.net/repos/asterisk-java/trunk/ Ah and while listing all those URLs, Asterisk-Java's bugtracker is available at http://jira.reucon.com/browse/AJ Asterisk-Java's official distribution site is http://www.asteriskjava.org/ Fisheye access is available at http://svn.reucon.net/fisheye/changelog/repos including very cool rss feeds for changes at http://svn.reucon.net/fisheye/rsscfg/repos If you are using Eclipse for development have a look at subclipse http://subclipse.tigris.org/ It integrates SVN into Eclipse the same way you are used to with the native CVS support offered by Eclipse. =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: Tony M. <to...@am...> - 2006-03-04 14:32:21
|
In case anybody has problems setting up SVN and MAVEN2 in their Eclipse environment here is what I did. I use Eclipse but have neither SVN (subversion), nor MAVEN2 experience, = yet I was able to download the source and quickly get the unit tests = running. I did it by: Adding the two update sites to my Eclipse plugin manager and downloading = the plugins: - Subversion plugin http://subclipse.tigris.org/ =20 - Maven 2 plugin http://m2eclipse.codehaus.org/ Configured Maven2 plugin: a) Go to menu window->preferences and configure a location for your = local maven jar repository folder (this is where jars will be automatically downloaded) Downloaded the asterisk-java project from SVN: a) Opened the newly installed "Eclipse SVN Repository Exploring = Perspective" (Window->Open Perspective) b) Created a new repository entry (right mouse click new repository = entry) using the following url: http://svn.reucon.net/repos/asterisk-java/trunk c) From the SVN repository view I checked out the trunk as a project = (did not use the New Project Creation wizard) Built and ran asterisk java unit tests: a) Right mouse clicked on the newly created project and selected Maven2->enable b) Selected Maven2->add dependencies (adds jars to classpath) c) Selected Maven2->add sources (adds src folders to src folder path) d) Selected src/test/java folder and "run as junit test" Tony -----Original Message----- From: ast...@li... [mailto:ast...@li...] On Behalf Of = Stefan Reuter Sent: Saturday, March 04, 2006 2:46 PM To: ast...@li... Subject: [Asterisk-java-users] Change from CVS to SVN Tony, yes I moved away from sourceforge's CVS due to several reasons: (a) Delay between developer CVS (master) and public CVS (replication) (b) Huge delay for changes to appear in fisheye (usually 24h) (c) write access to CVS was painful slow most of the time even completly unavailable from time to time (d) CVS sucks compared to SVN ;) (ok sf offeres experimental SVN, but with (a)-(c) I choose not to give it a try) (a) often resulted in problems with changes not being immediately available for testing by users and (b) rendered fisheye rather useless. Therefore the new source repository is available at http://svn.reucon.net/ with Asterisk-Java's trunk at http://svn.reucon.net/repos/asterisk-java/trunk/ Ah and while listing all those URLs, Asterisk-Java's bugtracker is available at http://jira.reucon.com/browse/AJ Asterisk-Java's official distribution site is http://www.asteriskjava.org/ Fisheye access is available at http://svn.reucon.net/fisheye/changelog/repos including very cool rss feeds for changes at http://svn.reucon.net/fisheye/rsscfg/repos If you are using Eclipse for development have a look at subclipse http://subclipse.tigris.org/ It integrates SVN into Eclipse the same way you are used to with the native CVS support offered by Eclipse. =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-04 11:19:46
|
I believe that there is a bug in the DefaultManagerConnection.sendAction(ManagerAction action, long timeout) method. The problem is with the creation of the ResponseHandlerResult. The ResponseHandlerResult calls thread.interrupt to wake up the thread which called sendAction. Thats fine, the problem begins when the sendAction returns (with or without a response). Calling Thread.interupt leaves the thread in an interrupted state until some method (such as sleep) checks the threads interrupt state at which point the interrupt state is cleared. The problem occurs if the call to interrupt is made when sendAction is not currently sleeping. There are numerous ways in which this can happen. The impact on sendAction is zero. However if an application then calls a method such as Thread.sleep or Queue.take the method call will immediately throw an Interrupted exception as the thread is still in an interrupted state. I believe a better way of dealing with this problem is to use Object.wait(x) and Object.notify. For the purposes of sendAction the affects are identical without the nasty side effects of calling interrupt. I hope this makes some sense. Regards, Brett. |
From: King H. <kin...@ne...> - 2006-03-04 11:31:43
|
I think I have also been bitten by this stray "interrupt" but I have not = gone so far as to track down where it was thrown.=20 I was having a queue.take() waiting for commands to send to the Asterisk = but it was being interrupted all the time :( =20 I have since changed to starting a new thread for each command to send = to Asterisk instead. I think this has the added benefit that a stuck = connection will not hang the whole program. King -----Original Message----- From: ast...@li... = [mailto:ast...@li...] On Behalf Of = Brett Sutton Sent: Saturday, March 04, 2006 7:19 PM To: ast...@li... Subject: [Asterisk-java-users] ManagerReader Interrupt I believe that there is a bug in the=20 DefaultManagerConnection.sendAction(ManagerAction action, long timeout)=20 method. The problem is with the creation of the ResponseHandlerResult. The ResponseHandlerResult calls thread.interrupt to wake up the thread=20 which called sendAction. Thats fine, the problem begins when the=20 sendAction returns (with or without a response). Calling Thread.interupt leaves the thread in an interrupted state until=20 some method (such as sleep) checks the threads interrupt state at which=20 point the interrupt state is cleared. The problem occurs if the call to interrupt is made when sendAction is=20 not currently sleeping. There are numerous ways in which this can = happen. The impact on sendAction is zero. However if an application then calls a = method such as Thread.sleep or Queue.take the method call will=20 immediately throw an Interrupted exception as the thread is still in an=20 interrupted state. I believe a better way of dealing with this problem is to use=20 Object.wait(x) and Object.notify. For the purposes of sendAction the=20 affects are identical without the nasty side effects of calling = interrupt. I hope this makes some sense. Regards, Brett. ------------------------------------------------------- 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-04 11:45:25
Attachments:
signature.asc
|
Interrupting the calling thread is probably a bug... Would changing this stuff to use notify help? King Ho wrote: > I think I have also been bitten by this stray "interrupt" but I have no= t gone so far as to track down where it was thrown.=20 >=20 > I was having a queue.take() waiting for commands to send to the Asteris= k but it was being interrupted all the time :( =20 >=20 > I have since changed to starting a new thread for each command to send = to Asterisk instead. I think this has the added benefit that a stuck conn= ection will not hang the whole program. >=20 > King >=20 > -----Original Message----- > From: ast...@li... [mailto:asterisk-= jav...@li...] On Behalf Of Brett Sutton > Sent: Saturday, March 04, 2006 7:19 PM > To: ast...@li... > Subject: [Asterisk-java-users] ManagerReader Interrupt >=20 > I believe that there is a bug in the=20 > DefaultManagerConnection.sendAction(ManagerAction action, long timeout)= =20 > method. >=20 > The problem is with the creation of the ResponseHandlerResult. >=20 > The ResponseHandlerResult calls thread.interrupt to wake up the thread = > which called sendAction. Thats fine, the problem begins when the=20 > sendAction returns (with or without a response). > Calling Thread.interupt leaves the thread in an interrupted state until= =20 > some method (such as sleep) checks the threads interrupt state at which= =20 > point the interrupt state is cleared. > The problem occurs if the call to interrupt is made when sendAction is = > not currently sleeping. There are numerous ways in which this can happe= n. > The impact on sendAction is zero. However if an application then calls = a=20 > method such as Thread.sleep or Queue.take the method call will=20 > immediately throw an Interrupted exception as the thread is still in an= =20 > interrupted state. >=20 > I believe a better way of dealing with this problem is to use=20 > Object.wait(x) and Object.notify. For the purposes of sendAction the=20 > affects are identical without the nasty side effects of calling interru= pt. >=20 > I hope this makes some sense. >=20 > Regards, > Brett. >=20 >=20 >=20 >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting lang= uage > that extends applications into web and mobile media. Attend the live we= bcast > and join the prime developer group breaking into this new coding territ= ory! > 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 >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting lang= uage > that extends applications into web and mobile media. Attend the live we= bcast > and join the prime developer group breaking into this new coding territ= ory! > http://sel.as-us.falkag.net/sel?cmd=3Dk&kid=110944&bid$1720&dat=121642 > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users --=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-04 12:06:24
|
Hi, I look through the code but can't find a way to login with Events turned = off. I know there is a LoginAction where I can call setEvents("off"). = But I can't send the action until I am already login. Am I missing = something? Thanks. King |
From: Stefan R. <sr...@re...> - 2006-03-04 12:28:32
Attachments:
signature.asc
|
King Ho wrote: > I look through the code but can't find a way to login with Events turne= d off. I know there is a LoginAction where I can call setEvents("off"). B= ut I can't send the action until I am already login. Am I missing somethi= ng? this is still missing in the ManagerConnection interface. I added a login(String events) method for 0.3 =3DStefan --=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-04 12:33:21
Attachments:
signature.asc
|
Brett Sutton wrote: > I believe a better way of dealing with this problem is to use > Object.wait(x) and Object.notify. For the purposes of sendAction the > affects are identical without the nasty side effects of calling interru= pt. >=20 > I hope this makes some sense. yes it makes a lot of sense. I followed your suggestion and it seems to work nicely. It also simplifies DefaultManagerConnection. Its in 0.3 now - if you have a chance please test the latest version from svn trunk: http://svn.reucon.net/repos/asterisk-java/trunk here is the diff: http://svn.reucon.net/fisheye/viewrep/repos/asterisk-java/trunk/src/main/= java/org/asteriskjava/manager/DefaultManagerConnection.java?r1=3D40&r2=3D= 81 Thanks! =3DStefan --=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-04 12:43:13
|
Is there any documentation describing the changes between 0.2 and 0.3? Thanks. King -----Original Message----- From: ast...@li... = [mailto:ast...@li...] On Behalf Of = Stefan Reuter Sent: Saturday, March 04, 2006 8:33 PM To: ast...@li... Subject: Re: [Asterisk-java-users] ManagerReader Interrupt Brett Sutton wrote: > I believe a better way of dealing with this problem is to use > Object.wait(x) and Object.notify. For the purposes of sendAction the > affects are identical without the nasty side effects of calling = interrupt. >=20 > I hope this makes some sense. yes it makes a lot of sense. I followed your suggestion and it seems to work nicely. It also simplifies DefaultManagerConnection. Its in 0.3 now - if you have a chance please test the latest version from svn trunk: http://svn.reucon.net/repos/asterisk-java/trunk here is the diff: http://svn.reucon.net/fisheye/viewrep/repos/asterisk-java/trunk/src/main/= java/org/asteriskjava/manager/DefaultManagerConnection.java?r1=3D40&r2=3D= 81 Thanks! =3DStefan --=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-04 12:59:32
Attachments:
signature.asc
|
King Ho wrote: > Is there any documentation describing the changes between 0.2 and 0.3? I wouldn't call it "documentation" yet but there is a very short ChangeLog available at http://svn.reucon.net/repos/asterisk-java/trunk/ChangeLog =3DStefan --=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: Brett S. <bs...@no...> - 2006-03-04 20:13:33
|
Stephan, Thanks for the fix. Is the 0.3 branch considered stable? Regards, Brett King Ho wrote: > Is there any documentation describing the changes between 0.2 and 0.3? > > Thanks. > > King > > -----Original Message----- > From: ast...@li... [mailto:ast...@li...] On Behalf Of Stefan Reuter > Sent: Saturday, March 04, 2006 8:33 PM > To: ast...@li... > Subject: Re: [Asterisk-java-users] ManagerReader Interrupt > > Brett Sutton wrote: > >> I believe a better way of dealing with this problem is to use >> Object.wait(x) and Object.notify. For the purposes of sendAction the >> affects are identical without the nasty side effects of calling interrupt. >> >> I hope this makes some sense. >> > > yes it makes a lot of sense. I followed your suggestion and it seems to > work nicely. It also simplifies DefaultManagerConnection. > Its in 0.3 now - if you have a chance please test the latest version > from svn trunk: > http://svn.reucon.net/repos/asterisk-java/trunk > > here is the diff: > http://svn.reucon.net/fisheye/viewrep/repos/asterisk-java/trunk/src/main/java/org/asteriskjava/manager/DefaultManagerConnection.java?r1=40&r2=81 > > Thanks! > > =Stefan > > |
From: Stefan R. <sr...@re...> - 2006-03-04 20:45:36
Attachments:
signature.asc
|
Brett Sutton wrote: > Is the 0.3 branch considered stable? no 0.3 is not yet stable put I plan to provide a release candidate for 0.3 in april. Neverthlesse I don't expect any major changes to the interfaces as long as you don't use org.asteriskjava.live. =3DStefan --=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: Brett S. <bs...@no...> - 2006-03-05 21:48:35
|
Is there any chance of getting the Interrupt bug fix back ported? Stefan Reuter wrote: > Brett Sutton wrote: > >> Is the 0.3 branch considered stable? >> > > no 0.3 is not yet stable put I plan to provide a release candidate for > 0.3 in april. Neverthlesse I don't expect any major changes to the > interfaces as long as you don't use org.asteriskjava.live. > > =Stefan > > |
From: Stefan R. <sr...@re...> - 2006-03-05 23:24:26
Attachments:
signature.asc
|
Brett Sutton wrote: > Is there any chance of getting the Interrupt bug fix back ported? =46rom a technical point of view that would be possible. But from an organisational point of view I would like to avoid it as 0.2 is still in CVS backporting it would rather mean reimplementing it. If you need the fix quickly I would prefer to release 0.3 earlier (say next week) and postpone the additions for org.asteriskjava.live for 0.4. Would that be an option for you? =3DStefan --=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-05 08:26:54
|
Hi, =20 I was test the robustness of Asterisk-Java with an un-stable Asterisk = server. That is, to see if there is any problem in Asterisk-Java = handling of server disconnects and reconnects. Below is the example = HelloEvents.java program with some minor modification so that the run() = methed will not exit: =20 public class HelloEvents implements ManagerEventHandler { private ManagerConnection managerConnection; =20 public HelloEvents() throws IOException { ManagerConnectionFactory factory =3D new = ManagerConnectionFactory("localhost", 5038, "username", "password"); this.managerConnection =3D factory.createManagerConnection(); } =20 public void run() throws IOException, AuthenticationFailedException, TimeoutException, InterruptedException { // register for events managerConnection.addEventHandler(this); =20 // connect to Asterisk and log in managerConnection.login(); =20 // request channel state managerConnection.sendAction(new StatusAction()); =20 while (true) { Thread.sleep(10000); }=20 =20 // and finally log off and disconnect //managerConnection.logoff(); } =20 public void handleEvent(ManagerEvent event) { // just print received events System.out.println(event); } =20 public static void main(String[] args) throws Exception { HelloEvents helloEvents; =20 helloEvents =3D new HelloEvents(); helloEvents.run(); } } =20 =20 =20 After stating the program I got the following from the console: =20 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:04 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connecting to 192.168.1.109 port 5038 org.asteriskjava.manager.event.ConnectEvent[dateReceived=3DSun Mar 05 = 16:12:05 GMT+08:00 2006,protocolidentifier=3D'Asterisk Call = Manager/1.0',systemHashcode=3D22507120] 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:05 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connected via Asterisk Call Manager/1.0 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:05 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Successfully logged in org.asteriskjava.manager.event.StatusCompleteEvent[dateReceived=3DSun = Mar 05 16:12:05 GMT+08:00 = 2006,internalactionid=3D'8949356_3',actionid=3D'null',systemHashcode=3D19= 647819] 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:05 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Determined Asterisk version: Asterisk 1.2 org.asteriskjava.manager.event.ShutdownEvent[dateReceived=3DSun Mar 05 = 16:12:14 GMT+08:00 = 2006,privilege=3D'system,all',restart=3D'false',shutdown=3D'Cleanly',syst= emHashcode=3D849515] org.asteriskjava.manager.event.DisconnectEvent[dateReceived=3DSun Mar 05 = 16:12:14 GMT+08:00 2006,systemHashcode=3D17171576] =20 =20 =20 This is all normal. Now, I do a =E2=80=9Crestart now=E2=80=9D on the = asterisk server and I got the following: =20 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Closing socket. org.asteriskjava.manager.event.ConnectEvent[dateReceived=3DSun Mar 05 = 16:21:16 GMT+08:00 2006,protocolidentifier=3D'Asterisk Call = Manager/1.0',systemHashcode=3D14372770] 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connecting to 192.168.1.109 port 5038 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connected via Asterisk Call Manager/1.0 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Successfully logged in 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Determined Asterisk version: Asterisk 1.0 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Successfully reconnected. org.asteriskjava.manager.event.RegistryEvent[dateReceived=3DSun Mar 05 = 16:21:18 GMT+08:00 = 2006,privilege=3D'system,all',domain=3D'152.104.231.22',username=3D'null'= ,cause=3D'null',status=3D'Registered',channel=3D'SIP',systemHashcode=3D20= 415955] =20 =20 =20 Notice the line which display the Asterisk version. It now says that it = is=20 =E2=80=9CAsterisk 1.0=E2=80=9D. I think this is caused by Asterisk-Java = having problem sending An action to determine the version of asterisk. =20 The connection seems to work fine for receiving events, it just have = problem sending Actions. =20 This test was done with Asterisk-Java 0.3, but I think the problem also = exists in 0.2. =20 =20 =20 Thanks. =20 King |
From: King H. <kin...@ne...> - 2006-03-05 10:18:42
|
Hi, =20 I was test the robustness of Asterisk-Java with an un-stable Asterisk = server. That is, to see if there is any problem in Asterisk-Java = handling of server disconnects and reconnects. Below is the example = HelloEvents.java program with some minor modification so that the run() = methed will not exit: =20 public class HelloEvents implements ManagerEventHandler { private ManagerConnection managerConnection; =20 public HelloEvents() throws IOException { ManagerConnectionFactory factory =3D new = ManagerConnectionFactory("localhost", 5038, "username", "password"); this.managerConnection =3D factory.createManagerConnection(); } =20 public void run() throws IOException, AuthenticationFailedException, TimeoutException, InterruptedException { // register for events managerConnection.addEventHandler(this); =20 // connect to Asterisk and log in managerConnection.login(); =20 // request channel state managerConnection.sendAction(new StatusAction()); =20 while (true) { Thread.sleep(10000); }=20 =20 // and finally log off and disconnect //managerConnection.logoff(); } =20 public void handleEvent(ManagerEvent event) { // just print received events System.out.println(event); } =20 public static void main(String[] args) throws Exception { HelloEvents helloEvents; =20 helloEvents =3D new HelloEvents(); helloEvents.run(); } } =20 =20 =20 After stating the program I got the following from the console: =20 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:04 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connecting to 192.168.1.109 port 5038 org.asteriskjava.manager.event.ConnectEvent[dateReceived=3DSun Mar 05 = 16:12:05 GMT+08:00 2006,protocolidentifier=3D'Asterisk Call = Manager/1.0',systemHashcode=3D22507120] 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:05 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connected via Asterisk Call Manager/1.0 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:05 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Successfully logged in org.asteriskjava.manager.event.StatusCompleteEvent[dateReceived=3DSun = Mar 05 16:12:05 GMT+08:00 = 2006,internalactionid=3D'8949356_3',actionid=3D'null',systemHashcode=3D19= 647819] 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:05 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Determined Asterisk version: Asterisk 1.2 org.asteriskjava.manager.event.ShutdownEvent[dateReceived=3DSun Mar 05 = 16:12:14 GMT+08:00 = 2006,privilege=3D'system,all',restart=3D'false',shutdown=3D'Cleanly',syst= emHashcode=3D849515] org.asteriskjava.manager.event.DisconnectEvent[dateReceived=3DSun Mar 05 = 16:12:14 GMT+08:00 2006,systemHashcode=3D17171576] =20 =20 =20 This is all normal. Now, I do a =E2=80=9Crestart now=E2=80=9D on the = asterisk server and I got the following: =20 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Closing socket. org.asteriskjava.manager.event.ConnectEvent[dateReceived=3DSun Mar 05 = 16:21:16 GMT+08:00 2006,protocolidentifier=3D'Asterisk Call = Manager/1.0',systemHashcode=3D14372770] 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connecting to 192.168.1.109 port 5038 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connected via Asterisk Call Manager/1.0 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Successfully logged in 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Determined Asterisk version: Asterisk 1.0 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Successfully reconnected. org.asteriskjava.manager.event.RegistryEvent[dateReceived=3DSun Mar 05 = 16:21:18 GMT+08:00 = 2006,privilege=3D'system,all',domain=3D'152.104.231.22',username=3D'null'= ,cause=3D'null',status=3D'Registered',channel=3D'SIP',systemHashcode=3D20= 415955] =20 =20 =20 Notice the line which display the Asterisk version. It now says that it = is=20 =E2=80=9CAsterisk 1.0=E2=80=9D. I think this is caused by Asterisk-Java = having problem sending An action to determine the version of asterisk. =20 The connection seems to work fine for receiving events, it just have = problem sending Actions. =20 This test was done with Asterisk-Java 0.3, but I think the problem also = exists in 0.2. =20 =20 =20 Thanks. =20 King |
From: King H. <kin...@ne...> - 2006-03-05 12:59:53
|
Hi, I was test the robustness of Asterisk-Java with an un-stable Asterisk = server. That is, to see if there is any problem in Asterisk-Java = handling of server disconnects and reconnects. Below is the example = HelloEvents.java program with some minor modification so that the run() = methed will not exit: public class HelloEvents implements ManagerEventHandler { private ManagerConnection managerConnection; public HelloEvents() throws IOException { ManagerConnectionFactory factory =3D new = ManagerConnectionFactory("localhost", 5038, "username", "password"); this.managerConnection =3D factory.createManagerConnection(); } public void run() throws IOException, AuthenticationFailedException, TimeoutException, InterruptedException { // register for events managerConnection.addEventHandler(this); =20 // connect to Asterisk and log in managerConnection.login(); // request channel state managerConnection.sendAction(new StatusAction()); =20 while (true) { Thread.sleep(10000); }=20 // and finally log off and disconnect //managerConnection.logoff(); } public void handleEvent(ManagerEvent event) { // just print received events System.out.println(event); } public static void main(String[] args) throws Exception { HelloEvents helloEvents; helloEvents =3D new HelloEvents(); helloEvents.run(); } } After stating the program I got the following from the console: 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:04 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connecting to 192.168.1.109 port 5038 org.asteriskjava.manager.event.ConnectEvent[dateReceived=3DSun Mar 05 = 16:12:05 GMT+08:00 2006,protocolidentifier=3D'Asterisk Call = Manager/1.0',systemHashcode=3D22507120] 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:05 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connected via Asterisk Call Manager/1.0 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:05 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Successfully logged in org.asteriskjava.manager.event.StatusCompleteEvent[dateReceived=3DSun = Mar 05 16:12:05 GMT+08:00 = 2006,internalactionid=3D'8949356_3',actionid=3D'null',systemHashcode=3D19= 647819] 2006/3/5 =E4=B8=8B=E5=8D=88 04:12:05 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Determined Asterisk version: Asterisk 1.2 org.asteriskjava.manager.event.ShutdownEvent[dateReceived=3DSun Mar 05 = 16:12:14 GMT+08:00 = 2006,privilege=3D'system,all',restart=3D'false',shutdown=3D'Cleanly',syst= emHashcode=3D849515] org.asteriskjava.manager.event.DisconnectEvent[dateReceived=3DSun Mar 05 = 16:12:14 GMT+08:00 2006,systemHashcode=3D17171576] This is all normal. Now, I do a =E2=80=9Crestart now=E2=80=9D on the = asterisk server and I got the following: 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Closing socket. org.asteriskjava.manager.event.ConnectEvent[dateReceived=3DSun Mar 05 = 16:21:16 GMT+08:00 2006,protocolidentifier=3D'Asterisk Call = Manager/1.0',systemHashcode=3D14372770] 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connecting to 192.168.1.109 port 5038 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Connected via Asterisk Call Manager/1.0 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Successfully logged in 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Determined Asterisk version: Asterisk 1.0 2006/3/5 =E4=B8=8B=E5=8D=88 04:21:16 = org.asteriskjava.util.impl.JavaLoggingLog info =E8=B3=87=E8=A8=8A: Successfully reconnected. org.asteriskjava.manager.event.RegistryEvent[dateReceived=3DSun Mar 05 = 16:21:18 GMT+08:00 = 2006,privilege=3D'system,all',domain=3D'152.104.231.22',username=3D'null'= ,cause=3D'null',status=3D'Registered',channel=3D'SIP',systemHashcode=3D20= 415955] Notice the line which display the Asterisk version. It now says that it = is=20 =E2=80=9CAsterisk 1.0=E2=80=9D. I think this is caused by Asterisk-Java = having problem sending An action to determine the version of asterisk. The connection seems to work fine for receiving events, it just have = problem sending Actions. This test was done with Asterisk-Java 0.3, but I think the problem also = exists in 0.2. Thanks. King |
From: Stefan R. <sr...@re...> - 2006-03-06 12:13:09
Attachments:
signature.asc
|
> Notice the line which display the Asterisk version. It now says that it= is=20 > =E2=80=9CAsterisk 1.0=E2=80=9D. I think this is caused by Asterisk-Java= having problem sending > An action to determine the version of asterisk. > The connection seems to work fine for receiving events, it just have pr= oblem sending > Actions. This is a rather nasty problem. Thanks for reporting it. In fact the connection works fine for receiving events and sending action= s. If didn't restart asterisk but unplugged the network cable the version would have been fine, too. The reason for A-J to determine the version in a reliable way after being restarted is the following: - to determine the version A-J sends a "show files version pbx.c" action - based on the results of this query A-J sets the version Now it seems that A-J reconnects that fast that Asterisk has not yet loaded all its stuff but is already accepting manager connections. What I geht looks like this: org.asteriskjava.manager.DefaultManagerConnection INFO - Connected via Asterisk Call Manager/1.0 2006-03-06 12:07:17,656 org.asteriskjava.manager.DefaultManagerConnection INFO - Successfully logged in org.asteriskjava.manager.response.CommandResponse: actionId=3D'null'; message=3D'null'; response=3D'Follows'; uniqueId=3D'null'; systemHashcode= =3D33018164 [File Revision , ---- -------- , pbx.c Revision: 10209 ] 2006-03-06 12:07:17,937 org.asteriskjava.manager.DefaultManagerConnection INFO - Determined Asterisk version: Asterisk 1.2 =2E.................2006-03-06 12:07:40,171 org.asteriskjava.manager.DefaultManagerConnection INFO - Closing socket. 2006-03-06 12:07:40,234 org.asteriskjava.manager.DefaultManagerConnection INFO - Connecting to 10.13.0.55 port 5038 2006-03-06 12:07:41,546 org.asteriskjava.manager.DefaultManagerConnection INFO - Connected via Asterisk Call Manager/1.0 -2006-03-06 12:07:43,062 org.asteriskjava.manager.DefaultManagerConnection INFO - Successfully logged in =2Eorg.asteriskjava.manager.response.CommandResponse: actionId=3D'null'; message=3D'null'; response=3D'Follows'; uniqueId=3D'null'; systemHashcode= =3D24212202 [Usage: show version, Shows Asterisk version information.] 2006-03-06 12:07:44,609 org.asteriskjava.manager.DefaultManagerConnection INFO - Determined Asterisk version: Asterisk 1.0 2006-03-06 12:07:44,609 org.asteriskjava.manager.DefaultManagerConnection INFO - Successfully reconnected. =2E!........................ Seems like I have to choose a different approach to determine the version= =2E.. =3DStefan --=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... |