[Freeswitch-users] Unstable hangup hook in javascript

Anthony Minessale anthony.minessale at gmail.com
Fri Jul 23 22:21:47 PDT 2010


fixed

On Fri, Jul 23, 2010 at 11:50 PM, xuyan yang <xyangni at gmail.com> wrote:

> A critical issue with this change,  FS crash everytime when session.hangup
> is called with a hook in place.
> The information from windows showing that the crash mod is js32.dll
>
> Would you please have a look at this problem?
>
> On Sat, Jul 24, 2010 at 11:28 AM, Anthony Minessale <
> anthony.minessale at gmail.com> wrote:
>
>> I mixed it up with lua.
>>
>>
>> return "exit";
>>
>> in your hanguphook to exit the script.
>>
>>
>> On Fri, Jul 23, 2010 at 8:33 PM, Sergey Okhapkin <
>> sos at sokhapkin.dyndns.org> wrote:
>>
>>> Makes sense then to use realtime call flow control from the script.
>>>
>>> On Friday 23 July 2010, xuyan yang wrote:
>>> > In my application, I seldom route calls. The task is to use FS as a
>>> > automated business coordinator over phone. Users call the system to
>>> update
>>> > their information and raise requests. The system collect these
>>> information
>>> > and upload to database. With real-time data, FS make decision and give
>>> out
>>> > instruction through SMS or out-going calls.
>>> > In this interesting situation, Freeswitch become Never-Switch, because
>>> it
>>> > takes the responsibility itself to communicate with each caller/callee
>>> > instead of switching to others.
>>> > That's why my script become complex.
>>> >
>>> > On Sat, Jul 24, 2010 at 8:03 AM, Sergey Okhapkin
>>> >
>>> > <sos at sokhapkin.dyndns.org>wrote:
>>> > > Which task do you want to accomplish? To me dynamic generation of FS
>>> > > dialplan
>>> > > from a script (language doesn't matter)  works better than realtime
>>> call
>>> > > flow
>>> > > control from a script, event socket etc. I do call routing, no PBX
>>> > > functions.
>>> > >
>>> > > On Friday 23 July 2010, xuyan yang wrote:
>>> > > > I know the solution of putting "if(!session.ready())exit()" to
>>> every
>>> > >
>>> > > check
>>> > >
>>> > > > point. But as my script already has nearly 3000 lines, there are
>>> too
>>> > > > many "if(!session.ready())exit()" to add.
>>> > > >
>>> > > > I tried error();  it works just because error is not defined. Using
>>> > > > intentional mistake to force exit is creative but strange.
>>> > > > After some thoughts I found that throw a user defined exception in
>>> the
>>> > >
>>> > > hook
>>> > >
>>> > > > may be a better way to force exit without the red [ERR] line.
>>> > > >
>>> > > > By the way, I still feel that let exit() in the hook stop the whole
>>> > >
>>> > > script
>>> > >
>>> > > > instead of the hook only seems to be more consistent because they
>>> are
>>> > > > not executed in separate thread. Would you please consider this if
>>> it
>>> > > > is not difficult? Thanks.
>>> > > >
>>> > > >
>>> > > > On Sat, Jul 24, 2010 at 6:17 AM, Anthony Minessale <
>>> > > >
>>> > > > anthony.minessale at gmail.com> wrote:
>>> > > > > if session.ready is false it means the channel is hungup.
>>> > > > >
>>> > > > > error(); will exit your script.
>>> > > > >
>>> > > > > you can probably remove some of them if you are getting better
>>> > > > > results with the patch.
>>> > > > >
>>> > > > > On Fri, Jul 23, 2010 at 4:56 PM, xuyan yang <xyangni at gmail.com>
>>> wrote:
>>> > > > >> 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>
>>> <MSN%3Aanthony_minessale at hotmail.c
>>> > > > >>>om><
>>> > >
>>> > > MSN%3Aanthony_minessale at hotmail.com<MSN%253Aanthony_minessale at hotmail.com>
>>> <MSN%253Aanthony_minessale at hotmail.com<MSN%25253Aanthony_minessale at hotmail.com>
>>> > >>
>>> > >
>>> > > > >>> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
>>> <PAYPAL%3Aanthony.mi
>>> > > > >>>nessale at gmail.com>
>>> > >
>>> > > <PAYPAL%3Aanthony.miness
>>> > >
>>> > > > >>>ale at gmail.com> IRC: irc.freenode.net #freeswitch
>>> > > > >>>
>>> > > > >>> FreeSWITCH Developer Conference
>>> > > > >>> sip:888 at conference.freeswitch.org<sip%3A888 at conference.freeswitch.org>
>>> <sip%3A888 at conference.freeswitch.o
>>> > > > >>>rg><
>>> > >
>>> > > sip%3A888 at conference.freeswitch.org<sip%253A888 at conference.freeswitch.org>
>>> <sip%253A888 at conference.freeswitch.org<sip%25253A888 at conference.freeswitch.org>
>>> > >>
>>> > >
>>> > > > >>> googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
>>> <googletalk%3Aconf%2B8
>>> > > > >>>88 at conference.freeswitch.org>
>>> > >
>>> > > <googletalk%3Aconf%2B888 at c
>>> > >
>>> > > > >>>onference.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-user
>>> > >
>>> > > > >>>s 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>
>>> <MSN%3Aanthony_minessale at hotmail.com<MSN%253Aanthony_minessale at hotmail.com>
>>> > > > >><
>>> > >
>>> > > MSN%3Aanthony_minessale at hotmail.com<MSN%253Aanthony_minessale at hotmail.com>
>>> <MSN%253Aanthony_minessale at hotmail.com<MSN%25253Aanthony_minessale at hotmail.com>
>>> > >>
>>> > >
>>> > > > > GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
>>> <PAYPAL%3Aanthony.mine
>>> > > > >ssale at gmail.com>
>>> > >
>>> > > <PAYPAL%3Aanthony.minessal
>>> > >
>>> > > > >e at gmail.com> IRC: irc.freenode.net #freeswitch
>>> > > > >
>>> > > > > FreeSWITCH Developer Conference
>>> > > > > sip:888 at conference.freeswitch.org<sip%3A888 at conference.freeswitch.org>
>>> <sip%3A888 at conference.freeswitch.org<sip%253A888 at conference.freeswitch.org>
>>> > > > >><
>>> > >
>>> > > sip%3A888 at conference.freeswitch.org<sip%253A888 at conference.freeswitch.org>
>>> <sip%253A888 at conference.freeswitch.org<sip%25253A888 at conference.freeswitch.org>
>>> > >>
>>> > >
>>> > > > > googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
>>> <googletalk%3Aconf%2B888
>>> > > > >@conference.freeswitch.org>
>>> > >
>>> > > <googletalk%3Aconf%2B888 at con
>>> > >
>>> > > > >ference.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
>>> > >
>>> > > _______________________________________________
>>> > > 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
>>
>>
>
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100724/3f944772/attachment-0001.html 


More information about the FreeSWITCH-users mailing list