pastebin the extension that calls this script and also the console log of the call from start to finish.<div>-MC<br><br><div class="gmail_quote">On Thu, Dec 15, 2011 at 8:14 PM, king2kin <span dir="ltr">&lt;<a href="mailto:xing2kin@yahoo.com">xing2kin@yahoo.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><div style="color:#000;background-color:#fff;font-family:times new roman,new york,times,serif;font-size:12pt"><div>
<span>MC,</span></div>
<div><span></span> </div>
<div><span>Thank you for your reply. The problem still exists even though I follow your advice to access the variable &#39;billsec&#39; after the channel hangup is complete.</span></div>
<div><span></span> </div>
<div><span>lua script: </span></div><span>
<div><span>{</span></div>
<div><span>session:answer()</span></div>
<div><span>.........</span></div>
<div><span>
<div><span>session:hangup()</span></div>
<div><span>session:sleep(1250)</span></div>
<div><span></span> </div></span></div>
<div><span>ctsec = session:getVariable(&#39;billsec&#39;)<br>freeswitch.consoleLog(&quot;INFO&quot;,&quot;***** Call-Time: sec=&quot; .. ctsec .. &quot;\n&quot;)<br></span></div>
<div><span>}</span></div></span>
<div> </div>
<div>freeswitch log info from console are copied as follows:</div>
<div>{</div>
<div><a href="mailto:freeswitch@W2k3T602" target="_blank">freeswitch@W2k3T602</a>&gt; 2011-12-16 12:06:01.187500 [INFO] switch_rtp.c:3152 Auto Ch<br>anging port from <a href="http://127.0.0.1:40036" target="_blank">127.0.0.1:40036</a> to <a href="http://192.168.0.119:40036" target="_blank">192.168.0.119:40036</a><br>
2011-12-16 12:06:03.234375 [INFO] switch_cpp.cpp:1199 Prompt file is &#39;ivr\ivr-we<br>lcome_to_freeswitch.wav&#39;<br>2011-12-16 12:06:19.156250 [NOTICE] switch_cpp.cpp:620 Hangup sofia/internal/sip<br>:<a href="http://1006@127.0.0.1:1312" target="_blank">1006@127.0.0.1:1312</a> [CS_EXECUTE] [NORMAL_CLEARING]<br>
<strong><font style="BACKGROUND-COLOR:#ff0000">2011-12-16 12:06:24.515625 [ERR] mod_lua.cpp:191 C:\c4dev\freeswitch\Release\scr<br>ipts/test1.lua:61: attempt to concatenate global &#39;ctsec&#39; (a nil value)<br>stack traceback:<br>
        C:\c4dev\freeswitch\Release\scripts/test1.lua:61: in main chunk</font><br></strong>2011-12-16 12:06:24.515625 [NOTICE] switch_core_session.c:1354 Session 6 (sofia/<br>internal/<a href="http://sip:1006@127.0.0.1:1312" target="_blank">sip:1006@127.0.0.1:1312</a>)
 Ended<br>2011-12-16 12:06:24.515625 [NOTICE] switch_core_session.c:1356 Close Channel sof<br>ia/internal/<a href="http://sip:1006@127.0.0.1:1312" target="_blank">sip:1006@127.0.0.1:1312</a> [CS_DESTROY]</div>
<div>}</div>
<div> </div>
<div>please continue to explain why this happens.</div>
<div> </div>
<div>x.k.</div>
<div><var></var> </div>
<div style="FONT-FAMILY:times new roman,new york,times,serif;FONT-SIZE:12pt">
<div style="FONT-FAMILY:times new roman,new york,times,serif;FONT-SIZE:12pt"><font face="Arial">
<div style="BORDER-BOTTOM:#ccc 1px solid;BORDER-LEFT:#ccc 1px solid;PADDING-BOTTOM:0px;LINE-HEIGHT:0;MARGIN:5px 0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;min-height:0px;FONT-SIZE:0px;BORDER-TOP:#ccc 1px solid;BORDER-RIGHT:#ccc 1px solid;PADDING-TOP:0px" readonly>
</div><b><span style="FONT-WEIGHT:bold">From:</span></b> Michael Collins &lt;<a href="mailto:msc@freeswitch.org" target="_blank">msc@freeswitch.org</a>&gt;<br><b><span style="FONT-WEIGHT:bold">To:</span></b> FreeSWITCH Users Help &lt;<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>&gt; <br>
<b><span style="FONT-WEIGHT:bold">Sent:</span></b> Wednesday, December 14, 2011 8:38 AM<br><b><span style="FONT-WEIGHT:bold">Subject:</span></b> Re: [Freeswitch-users] Question Answertime variable? billsec is not available<br>
</font><br>
<div>Are you trying to access these before the channel hangup is complete? If so then yes, they will always be empty. They are not populated until the call actually ends. Are you doing a hangup hook in Lua or something else?
<div><br></div>
<div>-MC<br><br>
<div>On Fri, Dec 9, 2011 at 10:03 PM, king2kin <span dir="ltr">&lt;<a href="mailto:xing2kin@yahoo.com" rel="nofollow" target="_blank">xing2kin@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex">
<div>
<div style="BACKGROUND-COLOR:#fff;FONT-FAMILY:times new roman,new york,times,serif;COLOR:#000;FONT-SIZE:12pt">
<div><span>The channel variables for this purpose seems to be </span></div>
<div><span>{duration, billsec, answersec, flow_billsec, mduration, billmsec, answermsec, uduration, billusec, answerusec}</span></div>
<div><span>see: source code &quot;switch_channel.c&quot;;</span></div>
<div><span>and wiki document on categories: channel variables</span></div>
<div><span>see: <a href="http://wiki.freeswitch.com/index.php?title=Category:Variable&amp;from=Variable+billmsec" target="_blank">http://wiki.freeswitch.com/index.php?title=Category:Variable&amp;from=Variable+billmsec</a>  </span></div>

<div><span></span> </div>
<div><span>However, when I tried to access these channel variables from Lua script or dialplan, their values are always &quot;nil&quot; or empty. </span></div>
<div><span></span> </div>
<div><span>-- dialplan:</span></div>
<div><span>{</span></div>
<div><span>   &lt;action application=&quot;answer&quot;/&gt;</span></div>
<div><span><span>    ........</span></span></div>
<div><span>   &lt;action application=&quot;log&quot; data=&quot;INFO billsec: ${billsec}; billmsec: ${billmsec}&quot;/&gt; <br>   &lt;action application=&quot;sleep&quot; data=&quot;2000&quot;/&gt;  <br>   &lt;action application=&quot;hangup&quot;/&gt;  </span></div>

<div><span>}</span></div>
<div><span><var></var></span> </div>
<div><span>-- Lua script:</span></div>
<div><span>2011-12-10 13:39:55.609375 [ERR] mod_lua.cpp:191 C:\c4dev\freeswitch\Release\scr<br>ipts/test1.lua:60: attempt to concatenate global &#39;ctsec&#39; (a nil value)<br>stack traceback:<br>        C:\c4dev\freeswitch\Release\scripts/test1.lua:60: in main chunk</span></div>

<div><span></span> </div>
<div><span>see:</span></div>
<div><span>{</span></div>
<div><span>session:answer()</span></div>
<div><span>.........</span></div>
<div><span>ctsec = session:getVariable(&#39;billsec&#39;)<br>ctmsec = session:getVariable(&#39;billmsec&#39;)<br>freeswitch.consoleLog(&quot;INFO&quot;,&quot;***** Call-Time: sec=&quot; .. ctsec .. &quot;\n&quot;)<br>freeswitch.consoleLog(&quot;INFO&quot;,&quot;***** Call-Time: msec=&quot; .. ctmsec .. &quot;\n&quot;)</span></div>

<div><span>session:hangup()</span></div>
<div><span>}</span></div>
<div><span></span> </div>
<div><br></div>
<div style="FONT-FAMILY:times new roman,new york,times,serif;FONT-SIZE:12pt">
<div style="FONT-FAMILY:times new roman,new york,times,serif;FONT-SIZE:12pt"><font face="Arial">
<div style="BORDER-BOTTOM:#ccc 1px solid;BORDER-LEFT:#ccc 1px solid;PADDING-BOTTOM:0px;LINE-HEIGHT:0;MARGIN:5px 0px;MIN-HEIGHT:0px;PADDING-LEFT:0px;PADDING-RIGHT:0px;FONT-SIZE:0px;BORDER-TOP:#ccc 1px solid;BORDER-RIGHT:#ccc 1px solid;PADDING-TOP:0px">
</div><b><span style="FONT-WEIGHT:bold">From:</span></b> curriegrad2004 &lt;<a href="mailto:curriegrad2004@gmail.com" rel="nofollow" target="_blank">curriegrad2004@gmail.com</a>&gt;<br><b><span style="FONT-WEIGHT:bold">To:</span></b> FreeSWITCH Users Help &lt;<a href="mailto:freeswitch-users@lists.freeswitch.org" rel="nofollow" target="_blank">freeswitch-users@lists.freeswitch.org</a>&gt; <br>
<b><span style="FONT-WEIGHT:bold">Sent:</span></b> Wednesday, November 30, 2011 11:15 PM<br><b><span style="FONT-WEIGHT:bold">Subject:</span></b> Re: [Freeswitch-users] Question Answertime
 variable?<br></font><br>billseconds or bill_msec would be the one to turn to.<br><br>On Wed, Nov 30, 2011 at 4:22 AM, Thomas Hoellriegel &lt;<a href="mailto:admin@blindi.net" rel="nofollow" target="_blank">admin@blindi.net</a>&gt; wrote:<br>
&gt; Hi all,<br>&gt; Is there a possibility to determine the caller time for a channel at<br>&gt; the end of a call?<br>&gt;<br>&gt; For example: in asterisk exists a variable:<br>&gt; ${ANSWEREDTIME}<br>&gt; I like to store the Answertime in a Database for example:<br>
&gt; Dailly minutes to call a Cellphone.<br>&gt; Can your help plese?<br>&gt; Thanks.<br>&gt;<br>&gt;<br>&gt; ---------------<br>&gt; Du kannst mich jederzeit kostenlos per Festnetz erreichen unter:<br>&gt; <a href="http://www.blindi.net/callback" target="_blank">http://www.blindi.net/callback</a><br>
&gt; homepage: <a href="http://www.blindi.net" target="_blank">http://www.blindi.net</a><br>&gt; blinde-misc mailingliste für blinde. anmeldung unter:<br>&gt; <a href="http://www.blindi.net/mailman/listinfo/blinde-misc" target="_blank">http://www.blindi.net/mailman/listinfo/blinde-misc</a><br>
&gt;<br>&gt;
 _________________________________________________________________________<br>&gt; Professional FreeSWITCH Consulting Services:<br>&gt; <a href="mailto:consulting@freeswitch.org" rel="nofollow" target="_blank">consulting@freeswitch.org</a><br>
&gt; <a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>&gt;<br>&gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>&gt; <a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
&gt;<br>&gt; Official FreeSWITCH Sites<br>&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>&gt; <a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
&gt; <a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>&gt;<br>&gt; FreeSWITCH-users mailing list<br>&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org" rel="nofollow" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="nofollow" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt; <a href="http://www.freeswitch.org/" rel="nofollow" target="_blank">http://www.freeswitch.org</a><br>&gt;<br><br>_________________________________________________________________________<br>Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" rel="nofollow" target="_blank">consulting@freeswitch.org</a><br><a href="http://www.freeswitchsolutions.com/" rel="nofollow" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br><a href="http://www.cudatel.com/" rel="nofollow" target="_blank">http://www.cudatel.com</a><br><br>Official FreeSWITCH Sites<br><a href="http://www.freeswitch.org/" rel="nofollow" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org/" rel="nofollow" target="_blank">http://wiki.freeswitch.org</a><br><a href="http://www.cluecon.com/" rel="nofollow" target="_blank">http://www.cluecon.com</a><br><br>FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" rel="nofollow" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="nofollow" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="nofollow" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br><a href="http://www.freeswitch.org/" rel="nofollow" target="_blank">http://www.freeswitch.org</a><br>
<br><br></div></div></div></div><br>_________________________________________________________________________<br>Professional FreeSWITCH Consulting Services:<br><a href="mailto:consulting@freeswitch.org" rel="nofollow" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com/" rel="nofollow" target="_blank">http://www.freeswitchsolutions.com</a><br><br>FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br><a href="http://www.cudatel.com/" rel="nofollow" target="_blank">http://www.cudatel.com</a><br>
<br>Official FreeSWITCH Sites<br><a href="http://www.freeswitch.org/" rel="nofollow" target="_blank">http://www.freeswitch.org</a><br><a href="http://wiki.freeswitch.org/" rel="nofollow" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com/" rel="nofollow" target="_blank">http://www.cluecon.com</a><br><br>FreeSWITCH-users mailing list<br><a href="mailto:FreeSWITCH-users@lists.freeswitch.org" rel="nofollow" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="nofollow" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="nofollow" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org/" rel="nofollow" target="_blank">http://www.freeswitch.org</a><br><br></blockquote></div><br></div></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><br></div></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></div>