<div dir="ltr"><div>John, the matching parenthesis is found on line 17, there&#39;s nothing wrong with the syntax of this file.<br><br></div>Bernhard, what i recommend is setup a separate extension that just does the conference logic for you, then in your lua code, instead of executing the &quot;conference&quot; stuff, simply transfer to your other XML extension that will put the call in a conference.  In my experience, FreeSWITCH automatically releases db handlers when a script exits, and this works fairly well for me.  <br><br>So i would remove your dbh:release() code, use a transfer. also make sure to do <br><pre>session:setAutoHangup(false)<br></pre><pre>before you transfer the call to your separate XML<br></pre></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 12, 2014 at 1:25 PM, John <span dir="ltr">&lt;<a href="mailto:freeswitch@earthspike.net" target="_blank">freeswitch@earthspike.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div>Bernhard,<br>
      <br>
      On line 5, you have more &#39;(&#39; than &#39;)&#39;. They need to balance.<span class="HOEnZb"><font color="#888888"><br>
      <br>
      John</font></span><div><div class="h5"><br>
      <br>
      On 12/10/14 18:27, Bernhard Wendel wrote:<br>
    </div></div></div><div><div class="h5">
    <blockquote type="cite">
      
      Hi John,<br>
      <br>
      what are you trying to tell me? <br>
      Since I&#39;m new to LUA you make me wonder whether there is a syntax
      error within my code. It should pop up somewhere, shouldn&#39;t it?
      Because I haven&#39;t found one and the code is actually working.<br>
      <br>
      Or am I missing something?<br>
      <br>
      Regards,<br>
      Bernhard<br>
      <br>
      <br>
      <div>Am 12.10.2014 17:21, schrieb John:<br>
      </div>
      <blockquote type="cite">
        
        It looks like the parentheses don&#39;t match on line 5.<br>
        <br>
        John<br>
        <br>
        <div>On 12/10/14 11:45, Bernhard Wendel
          wrote:<br>
        </div>
        <blockquote type="cite">
          
          Hi,<br>
          <br>
          I&#39;m using the following Lua-Script to check whether a
          conference exists and only let a caller join if so.<br>
          The script is called via the following dialplan <i>&lt;action
            application=&quot;lua&quot; data=&quot;/path/to/script.lua $1&quot; /&gt;</i><i>
          </i>, where $1 is the destination number.<br>
          <br>
          <br>
          <ol>
            <li>-- Connect to a database</li>
            <li>local dbh = freeswitch.Dbh(&quot;pgsql://hostaddr=127.0.0.1
              dbname=database user=username password=&#39;password&#39;
              application_name=&#39;my-lua-script&#39;&quot;)</li>
            <li>assert(dbh:connected());</li>
            <li>-- Execute SQL</li>
            <li>dbh:query(string.format(&quot;SELECT COUNT(*) as \&quot;MyCount\&quot;
              FROM \&quot;MyTable\&quot; WHERE ColA = &#39;%s&#39;&quot;, argv[1]),
              function(row)</li>
            <li>    --freeswitch.consoleLog(&quot;INFO&quot;, &quot;Results: &quot; ..
              row.MyCount)</li>
            <li>    </li>
            <li>    dbh:release()</li>
            <li>    </li>
            <li>    if (row.MyCount== &#39;1&#39;) then</li>
            <li>        freeswitch.consoleLog(&quot;INFO&quot;, &quot;User is joining
              conference at &quot; .. argv[1])</li>
            <li>        </li>
            <li>        session:answer()</li>
            <li>        session:execute(&quot;conference&quot;, argv[1] ..
              &quot;@wideband&quot;)</li>
            <li>    end</li>
            <li>    session:hangup()</li>
            <li>end)</li>
          </ol>
          <br>
          Line 8 instructs FS to return the postgres-Connection back to
          the pool - which is as expected. When a user now leaves the
          conference, FS throws this errors:<br>
          <br>
          2014-10-12 10:32:30.065924 [DEBUG] switch_cpp.cpp:694
          CoreSession::hangup<br>
          2014-10-12 10:32:30.065924 [CRIT] switch_pgsql.c:368 An error
          occurred trying to consume input for query (200): connection
          pointer is NULL<br>
          2014-10-12 10:32:30.065924 [CRIT] switch_pgsql.c:122 No DB
          Connection<br>
          2014-10-12 10:32:30.065924 [ERR] switch_core_sqldb.c:1177 ERR:
          [SELECT COUNT(*) as &quot;MyCount&quot; FROM &quot;MyTable&quot; WHERE ColA =
          &#39;conf-1234&#39;][connection pointer is NULL]<br>
          2014-10-12 10:32:30.065924 [ERR] freeswitch_lua.cpp:446 DBH
          NOT Connected.<br>
          2014-10-12 10:32:30.065924 [DEBUG] switch_cpp.cpp:1075 <a href="mailto:sofia/internal/Alice@my.pbx.com" target="_blank">sofia/internal/Alice@my.pbx.com</a>
          destroy/unlink session from object<br>
          <br>
          Now, I could live with that. BUT: The problem is, that
          sometimes, when a user leaves the conference, FS crashes.<br>
          I&#39;ve narrowed down the main cause to the above lua script. If
          I comment line 8 out, FS stops crashing. This will also stop
          FS from reusing Database-Connections. <br>
          <br>
          Now my questions:<br>
          <ol>
            <li>I don&#39;t use `dbh` after line 8. So where does the error
              come from?</li>
            <li>How can I stop the error?</li>
            <li>How can I rewrite the lua script to have both a)
              non-crashing FS and b) reusing of connection?</li>
          </ol>
          <p><br>
            Regards,<br>
            Bernhard<br>
          </p>
          <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>

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

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

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

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

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

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.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>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.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>
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></blockquote></div><br></div>