I added many <span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">session.ready() as below and re-do the test again.</span><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">the steps are:</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">1. type jsrun test.js   in fs_cli</span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">2. answer the call in x-lite.</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">3. when I hear the speech, hangup the call in about 1 second.</span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">4 check the log to find  &quot;</span></font><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">hangup!!!!!!!!!!!!!&quot;</span></div>
<div><br><div>the result is that</div><div> about half of the test failed to call hangup hook.</div><div>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.</div>
<div><br></div><div><br></div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div>////test.js</div><div>function on_hangup(session, how){</div>
<div><span style="white-space: pre-wrap; ">        </span>console_log(&quot;notice&quot;,&quot;hangup!!!!!!!!!!!!!\n&quot;);</div><div>}</div><div><br></div><div>session = new Session(&quot;sofia/gateway/12voip-out/*********&quot;);</div>
<div>session.waitForAnswer();</div><div>session.ready();</div><div>session.execute(&quot;set&quot;,&quot;continue_on_fail=true&quot;);</div><div>var res=session.setHangupHook(on_hangup);</div><div>console_log(&quot;notice&quot;,&quot;res:&quot;+res+&quot;\n&quot;);</div>
<div>if(session.ready())session.execute(&quot;speak&quot;, &quot;This is an example of flite text to speech engine. We can test the work of hanguphook.&quot;);</div><div>if(session.ready())session.execute(&quot;speak&quot;,&quot;you are calling from &quot; + session.caller_id_num + &quot; You are calling &quot; + session.destination );</div>
<div>session.ready();</div><div>session.hangup();</div></span></div><div><br><div class="gmail_quote">On Sat, Jul 24, 2010 at 1:08 AM, Anthony Minessale <span dir="ltr">&lt;<a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><p>It checks before and after blocking calls like that.<br>
</p>
<p></p><blockquote type="cite"><div class="im">On Jul 23, 2010 11:53 AM, &quot;Dan&quot; &lt;<a href="mailto:freeswitch-users@digitaldan.com" target="_blank">freeswitch-users@digitaldan.com</a>&gt; wrote:<br><br></div><div>
<div style="font-family:Times New Roman;font-size:12pt;color:#000000"><div class="im">
So If I call session.recordFile which blocks in code until the user hangs up, and can&#39;t make periodic calls to session.ready,  is the hangup hook not realiable in this scenario?  <br><br><hr><b>From: </b>&quot;Anthony Minessale&quot; &lt;<a href="mailto:anthony.minessale@gmail.com" target="_blank">anthony.minessale@gmail.com</a>&gt;<br>

<b>To: </b>&quot;FreeSWITCH Users Help&quot; &lt;<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>&gt;<br><b>Sent: </b>Thursday, July 22, 2010 10:30:48 AM<br>

<b>Subject: </b>Re: [Freeswitch-users] Unstable hangup hook in javascript</div><p><font color="#500050"><br><br>You must make periodic calls to session.ready() or some other freeswitch api functions to trigger ...</font></p>
</div>
</div><div class="im"><br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></div></blockquote><p></p>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div></div>