<div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">These scenario only occurs when initial lua script is running forever ( or in loop for period of time ). </div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
Initially, I thought calls had been transfer and hangup separately, Lua standard garbage collection ( using local variable on &quot;new_session&quot;) will take care of cleaning up the var. So it shouldn&#39;t lockup the channels.</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
But,  as what been said </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
============</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">The sessions are tied to the garbage collector so until the script frees the script version of the session the core can&#39;t free the real version.</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
the  :destroy() method detaches the 2 so the channel can hangup on its own and you only save the shell of the wrapper in your GC.</div></div><div>============</div><div><br></div><div>So, the key is on destroy method. this already documented in wiki, I just wasn&#39;t sure what it meant before.</div>
<div><br></div><br><div class="gmail_quote">On Thu, Apr 11, 2013 at 2:25 PM, Abaci <span dir="ltr">&lt;<a href="mailto:abaci64@gmail.com" target="_blank">abaci64@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">

  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>Can you please document this on the
      wiki.<div><div class="h5"><br>
      <br>
      On 4/10/2013 5:13 PM, Johny Kadarisman Kwan wrote:<br>
    </div></div></div><div><div class="h5">
    <blockquote type="cite">
      <div>
        <div>Cool, Thank you</div>
        <div><br>
        </div>
        <div>It works now! no more stale session</div>
        <div><br>
        </div>
        <div>session:destroy() and assigned nullable after transfer
          seems enough on this case</div>
        <div><br>
        </div>
        <div>=================== SimpleDialer.lua (after suggestion from
          Anthony) ============</div>
        <div>
          <div dir="ltr"><br>
          </div>
          <div dir="ltr">local threadName = &quot;SimpleDialer&quot;<br>
          </div>
        </div>
        <div><br>
        </div>
        <div>while true do                             </div>
        <div>                                                           
                                                     </div>
        <div>        freeswitch.consoleLog(&quot;info&quot;, threadName..&quot;
          ticking\n&quot;)                                                  
                                                          </div>
        <div>        -- task run here</div>
        <div>        local new_session =
          freeswitch.Session(&#39;sofia/gateway/vox/<a href="tel:%2B15085895115" value="+15085895115" target="_blank">+150</a>88888888&#39;)</div>
        <div>        new_session:transfer(&quot;echo&quot;, &quot;XML&quot;, &quot;default&quot;)</div>
        <div>        new_session:destroy()</div>
        <div>        new_session = nil</div>
        <div><br>
        </div>
        <div>        freeswitch.msleep(60000)</div>
        <div>end</div>
      </div>
      <div><br>
      </div>
      <br>
      <div class="gmail_quote">On Wed, Apr 10, 2013 at 4:17 PM, 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">
          <div dir="ltr">try
            <div><br>
            </div>
            <div>new_session:setAutoHangup(0);</div>
            <div>new_session:destroy();</div>
            <div><br>
            </div>
            <div>before you transfer it.</div>
            <div>and </div>
            <div><br>
            </div>
            <div>
              new_session = undefined;</div>
            <div><br>
            </div>
            <div>after you transfer it.</div>
            <div><br>
            </div>
            <div>The sessions are tied to the garbage collector so until
              the script frees the script version of the session the
              core can&#39;t free the real version.</div>
            <div><br>
            </div>
            <div>the  :destroy() method detaches the 2 so the channel
              can hangup on its own and you only save the shell of the
              wrapper in your GC.</div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
          </div>
          <div class="gmail_extra"><br>
            <br>
            <div class="gmail_quote">
              <div>
                <div>On Wed, Apr 10, 2013 at 2:34 PM, Johny
                  Kadarisman Kwan <span dir="ltr">&lt;<a href="mailto:jkr888@gmail.com" target="_blank">jkr888@gmail.com</a>&gt;</span>
                  wrote:<br>
                </div>
              </div>
              <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div>
                  <div>
                    <div dir="ltr">I have lua &#39;background&#39; script that
                      wake up every few seconds, and check to perform
                      specific task, one of it to established call.</div>
                    <div dir="ltr">Calls are then initiated then
                      transfer to some extension in dialplan. The
                      scripts has been running and works as expected.</div>
                    <div dir="ltr">But after session ended(hangup),
                      channels is not released and can be seen using cli
                      &quot;show channels&quot;. and trying to kill such channel
                      result in &quot;-ERR No Such Channel!&quot;</div>
                    <div dir="ltr">
                      <br>
                    </div>
                    <div dir="ltr">This seems being reported before, but
                      I can&#39;t seems to find any resolution.</div>
                    <div dir="ltr"><br>
                    </div>
                    <div dir="ltr">Following simple script could
                      replicate the issues : </div>
                    <div dir="ltr">
                      <br>
                    </div>
                    <div dir="ltr">freeswitch&gt; luarun
                      SimpleDialer.lua</div>
                    <div dir="ltr"><br>
                    </div>
                    <div dir="ltr">=================== SimpleDialer.lua</div>
                    <div dir="ltr"><br>
                    </div>
                    <div dir="ltr">local threadName = &quot;SimpleDialer&quot;<br>
                      <div><br>
                      </div>
                      <div>
                        <div>while true do                             </div>
                        <div>                                           
                                                                       
                                       </div>
                        <div>        freeswitch.consoleLog(&quot;info&quot;,
                          threadName..&quot; ticking\n&quot;)                    
                                                                       
                                                           </div>
                        <div>        -- task run here</div>
                        <div>        local new_session =
                          freeswitch.Session(&#39;sofia/gateway/vox/<a href="tel:%2B15085895115" value="+15085895115" target="_blank">+150</a>88888888&#39;)</div>
                        <div>        new_session:transfer(&quot;echo&quot;, &quot;XML&quot;,
                          &quot;default&quot;)</div>
                        <div><br>
                        </div>
                        <div>        freeswitch.msleep(60000)</div>
                        <div>end</div>
                      </div>
                      <div><br>
                      </div>
                      <div>============= dialplan entry</div>
                      <div><br>
                      </div>
                      <div>
                        <div>    &lt;extension name=&quot;echo&quot;&gt;</div>
                        <div>      &lt;condition
                          field=&quot;destination_number&quot;
                          expression=&quot;^echo$&quot;&gt;</div>
                        <div>              &lt;action application=&quot;echo&quot;
                          data=&quot;&quot;/&gt;</div>
                        <div>      &lt;/condition&gt;</div>
                        <div>    &lt;/extension&gt;        </div>
                      </div>
                      <div><br>
                      </div>
                    </div>
                    <br>
                  </div>
                </div>
_________________________________________________________________________<br>
                Professional FreeSWITCH Consulting Services:<br>
                <a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
                <a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
                <br>
                FreeSWITCH-powered IP PBX: The CudaTel Communication
                Server<br>
                <a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
                <br>
                Official FreeSWITCH Sites<br>
                <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
                <a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
                <a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><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">
            <div><br>
            </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:<a href="tel:%2B19193869900" value="+19193869900" target="_blank">+19193869900</a>
          </div>
          <br>
_________________________________________________________________________<br>
          Professional FreeSWITCH Consulting Services:<br>
          <a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
          <a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
          <br>
          FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
          <a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
          <br>
          Official FreeSWITCH Sites<br>
          <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
          <a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
          <a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><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>
      <fieldset></fieldset>
      <br>
      <pre>_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a>

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a>

Official FreeSWITCH Sites
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a>

FreeSWITCH-users mailing list
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><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>