[Freeswitch-users] Unstable hangup hook in javascript

Dan freeswitch-users at digitaldan.com
Fri Jul 23 09:47:03 PDT 2010


So If I call session.recordFile which blocks in code until the user hangs up, and can't make periodic calls to session.ready, is the hangup hook not realiable in this scenario? 


From: "Anthony Minessale" <anthony.minessale at gmail.com> 
To: "FreeSWITCH Users Help" <freeswitch-users at lists.freeswitch.org> 
Sent: Thursday, July 22, 2010 10:30:48 AM 
Subject: Re: [Freeswitch-users] Unstable hangup hook in javascript 

You must make periodic calls to session.ready() or some other freeswitch api functions to trigger the hangup hook. 
The hangup hook in scripts must be executed by your call's thread, if another thread does the hangup on your channel, it queues in the internal object that it needs to call the hanguphook method. This is triggered by doing anything new in your script. So if your channel is blocking on something while its being hungup, it will eventually pick up on it when it exits the blocking call and runs one of many methods that have a check for if it has to run the hangup hook. Manually calling hangup is a bad example, because you know you are hanging up so there is no real need to trigger the hanguphook but if you want to ensure it does you have to call session.ready() one last time. 


If you are writing a critical application, consider C. It's much more robust when it comes to this type of problem because it supports threading. Or consider ESL external scripts where you can run async operations and get events etc. 









On Thu, Jul 22, 2010 at 10:55 AM, Chris Fowler <chris at fowler.cc> wrote: 






Did this topic get resolved? We’re seeing the same occasional problem using LUA scripts where on occasion the hangup hook doesn’t get called. 



Our app for this is the 24x7 emergency paging system for our customers – so we’d like to resolve! 



This in on our production system (which is very stable) – hence the out of date build: FreeSWITCH Version 1.0.trunk (16535). 



Thanks, Chris. 




From: freeswitch-users-bounces at lists.freeswitch.org [mailto: freeswitch-users-bounces at lists.freeswitch.org ] On Behalf Of xuyan yang 
Sent: Sunday, July 11, 2010 08:08 
To: freeswitch-users at lists.freeswitch.org 
Subject: [Freeswitch-users] Unstable hangup hook in javascript 








Hi, 






I have tested the hangup hook function using the following javascript. During the speech in the call I hangup the call to see the result. Sometimes hangup function works, but sometimes it did not. The chance of fail is about 1 out of 10. I am running windows XP, FS git version cloned and compiled at end of Jun. Does anyone meet the same problem? Or do I make some mistake in the script? Thanks. 










////test.js 


function on_hangup(session, how){ 


console_log("notice","hangup!!!!!!!!!!!!!\n"); 


} 






session = new Session("sofia/gateway/12voip-out/*********"); 






session.waitForAnswer(); 


session.execute("set","continue_on_fail=true"); 


var res=session.setHangupHook(on_hangup); 


console_log("notice","res:"+res+"\n"); 


session.execute("speak", "This is an example of flite text to speech engine. We can test the work of hanguphook."); 


session.execute("speak","you are calling from " + session.caller_id_num + " You are calling " + session.destination ); 


session.hangup(); 




_______________________________________________ 
FreeSWITCH-users mailing list 
FreeSWITCH-users at lists.freeswitch.org 
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users 
UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users 
http://www.freeswitch.org 




-- 
Anthony Minessale II 

FreeSWITCH http://www.freeswitch.org/ 
ClueCon http://www.cluecon.com/ 
Twitter: http://twitter.com/FreeSWITCH_wire 

AIM: anthm 
MSN:anthony_minessale at hotmail.com 
GTALK/JABBER/ PAYPAL:anthony.minessale at gmail.com 
IRC: irc.freenode.net #freeswitch 

FreeSWITCH Developer Conference 
sip:888 at conference.freeswitch.org 
googletalk:conf+888 at conference.freeswitch.org 
pstn:+19193869900 

_______________________________________________ 
FreeSWITCH-users mailing list 
FreeSWITCH-users at lists.freeswitch.org 
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users 
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users 
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100723/2f2d0245/attachment.html 


More information about the FreeSWITCH-users mailing list