if session.ready is false it means the channel is hungup.<div><div><br></div><div><div>error(); will exit your script.</div><div><br></div><div>you can probably remove some of them if you are getting better results with the patch.</div>
<div><br></div><div><br><br><div class="gmail_quote">On Fri, Jul 23, 2010 at 4:56 PM, xuyan yang <span dir="ltr">&lt;<a href="mailto:xyangni@gmail.com">xyangni@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;">
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. <div><br></div><div>But this behaviour change caused another problem as I still need to stop the script when the session is hangup. </div>

<div>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 &quot;return&quot;. That means exit() in hangup hook only stops the hook while the main program can not be stopped.</div>

<div><br></div><div>Is there any good solution to stop the script immediately when hangup?</div><div><div></div><div class="h5"><div><br><div class="gmail_quote">On Sat, Jul 24, 2010 at 3:13 AM, Anthony Minessale <span dir="ltr">&lt;<a href="mailto:anthony.minessale@gmail.com" target="_blank">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">give lastest HEAD a try, I pushed in some more checks and made calling session.hangup() nonfatal when it&#39;s already hungup.<div>

<br><div><div><div></div><div><br><div class="gmail_quote">On Fri, Jul 23, 2010 at 1:27 PM, xuyan yang <span dir="ltr">&lt;<a href="mailto:xyangni@gmail.com" target="_blank">xyangni@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">I added many <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 face="arial, sans-serif"><span style="border-collapse:collapse">the steps are:</span></font></div>
<div><font face="arial, sans-serif"><span style="border-collapse:collapse">1. type jsrun test.js   in fs_cli</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">2. answer the call in x-lite.</span></font></div>



<div><font face="arial, sans-serif"><span style="border-collapse:collapse">3. when I hear the speech, hangup the call in about 1 second.</span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse">4 check the log to find  &quot;</span></font><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 style="font-family:arial, sans-serif;font-size:13px;border-collapse:collapse"><div><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><div>session.ready();</div><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><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><div></div><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" target="_blank">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>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>
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><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" 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></blockquote></div><br></div></div></div></div>
<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></blockquote></div><br><br clear="all"><br></div></div><div>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com/</a><br>


Twitter: <a href="http://twitter.com/FreeSWITCH_wire" target="_blank">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com" target="_blank">MSN:anthony_minessale@hotmail.com</a><br>

GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com" target="_blank">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org" target="_blank">sip:888@conference.freeswitch.org</a><br>

<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org" target="_blank">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:+19193869900<br>
</div></div></div>
<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></blockquote></div><br></div>
</div></div><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><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>
Twitter: <a href="http://twitter.com/FreeSWITCH_wire">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br><a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br><a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:+19193869900<br>
</div></div></div>