<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Can you please document this on the
      wiki.<br>
      <br>
      On 4/10/2013 5:13 PM, Johny Kadarisman Kwan wrote:<br>
    </div>
    <blockquote
cite="mid:CAMPUO6J3cxqWNYMOi-XCYcBXEP80o4E9C_szLsa-rB7Ny3bKvg@mail.gmail.com"
      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 = "SimpleDialer"<br>
          </div>
        </div>
        <div><br>
        </div>
        <div>while true do &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; freeswitch.consoleLog("info", threadName.."
          ticking\n") &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; -- task run here</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; local new_session =
          freeswitch.Session('sofia/gateway/vox/<a
            moz-do-not-send="true" href="tel:%2B15085895115"
            value="+15085895115" target="_blank">+150</a>88888888')</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; new_session:transfer("echo", "XML", "default")</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; new_session:destroy()</div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; new_session = nil</div>
        <div><br>
        </div>
        <div>&nbsp; &nbsp; &nbsp; &nbsp; 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 moz-do-not-send="true"
            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&nbsp;</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't free the real version.</div>
            <div><br>
            </div>
            <div>the &nbsp;: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 class="h5">On Wed, Apr 10, 2013 at 2:34 PM, Johny
                  Kadarisman Kwan <span dir="ltr">&lt;<a
                      moz-do-not-send="true"
                      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 class="h5">
                    <div dir="ltr">I have lua 'background' 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
                      "show channels". and trying to kill such channel
                      result in "-ERR No Such Channel!"</div>
                    <div dir="ltr">
                      <br>
                    </div>
                    <div dir="ltr">This seems being reported before, but
                      I can't seems to find any resolution.</div>
                    <div dir="ltr"><br>
                    </div>
                    <div dir="ltr">Following simple script could
                      replicate the issues :&nbsp;</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 = "SimpleDialer"<br>
                      <div><br>
                      </div>
                      <div>
                        <div>while true do &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; freeswitch.consoleLog("info",
                          threadName.." ticking\n") &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; -- task run here</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; local new_session =
                          freeswitch.Session('sofia/gateway/vox/<a
                            moz-do-not-send="true"
                            href="tel:%2B15085895115"
                            value="+15085895115" target="_blank">+150</a>88888888')</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; new_session:transfer("echo", "XML",
                          "default")</div>
                        <div><br>
                        </div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; freeswitch.msleep(60000)</div>
                        <div>end</div>
                      </div>
                      <div><br>
                      </div>
                      <div>============= dialplan entry</div>
                      <div><br>
                      </div>
                      <div>
                        <div>&nbsp; &nbsp; &lt;extension name="echo"&gt;</div>
                        <div>&nbsp; &nbsp; &nbsp; &lt;condition
                          field="destination_number"
                          expression="^echo$"&gt;</div>
                        <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;action application="echo"
                          data=""/&gt;</div>
                        <div>&nbsp; &nbsp; &nbsp; &lt;/condition&gt;</div>
                        <div>&nbsp; &nbsp; &lt;/extension&gt; &nbsp; &nbsp; &nbsp; &nbsp;</div>
                      </div>
                      <div><br>
                      </div>
                    </div>
                    <br>
                  </div>
                </div>
_________________________________________________________________________<br>
                Professional FreeSWITCH Consulting Services:<br>
                <a moz-do-not-send="true"
                  href="mailto:consulting@freeswitch.org"
                  target="_blank">consulting@freeswitch.org</a><br>
                <a moz-do-not-send="true"
                  href="http://www.freeswitchsolutions.com"
                  target="_blank">http://www.freeswitchsolutions.com</a><br>
                <br>
                FreeSWITCH-powered IP PBX: The CudaTel Communication
                Server<br>
                <a moz-do-not-send="true" href="http://www.cudatel.com"
                  target="_blank">http://www.cudatel.com</a><br>
                <br>
                Official FreeSWITCH Sites<br>
                <a moz-do-not-send="true"
                  href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
                <a moz-do-not-send="true"
                  href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
                <a moz-do-not-send="true" href="http://www.cluecon.com"
                  target="_blank">http://www.cluecon.com</a><br>
                <br>
                FreeSWITCH-users mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:FreeSWITCH-users@lists.freeswitch.org"
                  target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
                <a moz-do-not-send="true"
                  href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users"
                  target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
                UNSUBSCRIBE:<a moz-do-not-send="true"
                  href="http://lists.freeswitch.org/mailman/options/freeswitch-users"
                  target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
                <a moz-do-not-send="true"
                  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 moz-do-not-send="true"
              href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org/</a><br>
            ClueCon <a moz-do-not-send="true"
              href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com/</a><br>
            Twitter: <a moz-do-not-send="true"
              href="http://twitter.com/FreeSWITCH_wire" target="_blank">http://twitter.com/FreeSWITCH_wire</a><br>
            <br>
            AIM: anthm<br>
            <a moz-do-not-send="true"
              href="mailto:MSN%3Aanthony_minessale@hotmail.com"
              target="_blank">MSN:anthony_minessale@hotmail.com</a><br>
            GTALK/JABBER/<a moz-do-not-send="true"
              href="mailto:PAYPAL%3Aanthony.minessale@gmail.com"
              target="_blank">PAYPAL:anthony.minessale@gmail.com</a><br>
            IRC: <a moz-do-not-send="true"
              href="http://irc.freenode.net" target="_blank">irc.freenode.net</a>
            #freeswitch<br>
            <br>
            FreeSWITCH Developer Conference<br>
            <a moz-do-not-send="true"
              href="mailto:sip%3A888@conference.freeswitch.org"
              target="_blank">sip:888@conference.freeswitch.org</a><br>
            <a moz-do-not-send="true"
              href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org"
              target="_blank">googletalk:conf+888@conference.freeswitch.org</a><br>
            pstn:<a moz-do-not-send="true" href="tel:%2B19193869900"
              value="+19193869900" target="_blank">+19193869900</a>
          </div>
          <br>
_________________________________________________________________________<br>
          Professional FreeSWITCH Consulting Services:<br>
          <a moz-do-not-send="true"
            href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
          <a moz-do-not-send="true"
            href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
          <br>
          FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
          <a moz-do-not-send="true" href="http://www.cudatel.com"
            target="_blank">http://www.cudatel.com</a><br>
          <br>
          Official FreeSWITCH Sites<br>
          <a moz-do-not-send="true" href="http://www.freeswitch.org"
            target="_blank">http://www.freeswitch.org</a><br>
          <a moz-do-not-send="true" href="http://wiki.freeswitch.org"
            target="_blank">http://wiki.freeswitch.org</a><br>
          <a moz-do-not-send="true" href="http://www.cluecon.com"
            target="_blank">http://www.cluecon.com</a><br>
          <br>
          FreeSWITCH-users mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
          <a moz-do-not-send="true"
            href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users"
            target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
          UNSUBSCRIBE:<a moz-do-not-send="true"
            href="http://lists.freeswitch.org/mailman/options/freeswitch-users"
            target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
          <a moz-do-not-send="true" href="http://www.freeswitch.org"
            target="_blank">http://www.freeswitch.org</a><br>
          <br>
        </blockquote>
      </div>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
<a class="moz-txt-link-abbreviated" href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a>

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
<a class="moz-txt-link-freetext" href="http://www.cudatel.com">http://www.cudatel.com</a>

Official FreeSWITCH Sites
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://wiki.freeswitch.org">http://wiki.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://www.cluecon.com">http://www.cluecon.com</a>

FreeSWITCH-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>