[Freeswitch-users] Unstable hangup hook in javascript

xuyan yang xyangni at gmail.com
Fri Jul 23 14:56:49 PDT 2010


Thanks for your update. I have tested it again base on the latest git tree,
the hangup hook does work every time and the script continue to run without
error message.

But this behaviour change caused another problem as I still need to stop the
script when the session is hangup.
Adding if(session.ready()) to every line of my script does not seem to be a
good solution. So I decided to call exit() in the hangup hook. However the
test result is that exit() in hangup hook only works the same as "return".
That means exit() in hangup hook only stops the hook while the main program
can not be stopped.

Is there any good solution to stop the script immediately when hangup?

On Sat, Jul 24, 2010 at 3:13 AM, Anthony Minessale <
anthony.minessale at gmail.com> wrote:

> give lastest HEAD a try, I pushed in some more checks and made calling
> session.hangup() nonfatal when it's already hungup.
>
>
> On Fri, Jul 23, 2010 at 1:27 PM, xuyan yang <xyangni at gmail.com> wrote:
>
>> I added many session.ready() as below and re-do the test again.
>> the steps are:
>> 1. type jsrun test.js   in fs_cli
>> 2. answer the call in x-lite.
>> 3. when I hear the speech, hangup the call in about 1 second.
>> 4 check the log to find  "hangup!!!!!!!!!!!!!"
>>
>> the result is that
>>  about half of the test failed to call hangup hook.
>> in all tests the script end up with [ERR] inline:1 Session is not active!
>>    then the script stopped and session.ready() near the end can not get the
>> chance to run.
>>
>>
>>
>> ////test.js
>> function on_hangup(session, how){
>>  console_log("notice","hangup!!!!!!!!!!!!!\n");
>> }
>>
>> session = new Session("sofia/gateway/12voip-out/*********");
>> session.waitForAnswer();
>> session.ready();
>> session.execute("set","continue_on_fail=true");
>> var res=session.setHangupHook(on_hangup);
>> console_log("notice","res:"+res+"\n");
>> if(session.ready())session.execute("speak", "This is an example of flite
>> text to speech engine. We can test the work of hanguphook.");
>> if(session.ready())session.execute("speak","you are calling from " +
>> session.caller_id_num + " You are calling " + session.destination );
>> session.ready();
>> session.hangup();
>>
>> On Sat, Jul 24, 2010 at 1:08 AM, Anthony Minessale <
>> anthony.minessale at gmail.com> wrote:
>>
>>> It checks before and after blocking calls like that.
>>>
>>> On Jul 23, 2010 11:53 AM, "Dan" <freeswitch-users at digitaldan.com> wrote:
>>>
>>>  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 ...
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>>
>> _______________________________________________
>> 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 <MSN%3Aanthony_minessale at hotmail.com>
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
> IRC: irc.freenode.net #freeswitch
>
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
> googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 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/20100724/acd1547f/attachment-0001.html 


More information about the FreeSWITCH-users mailing list