[OpenSIPS-Users] LUA AVP issue?

Gledhill, James james.gledhill at sipstorm.com
Fri Jun 15 15:18:08 CEST 2012


Razvan,

 

If I can reproduce it again I will turn on full logs and send it.  In
the example code that produced the results below (my original post)
$avpi(jimmy) was not initialized anywhere, I just used get to print the
results.  It may be a simple misunderstanding I have about AVPs, as I am
learning more about them.  I have a long history with SIP (with other
software) and with Lua, but am new at opensips and understanding how
AVPs work.  

 

In previous versions of testing I DID set $avp(jimmy) to a number of
string values in both opensips cfg file as well as in LUA.  Obviously
when I changed the cfg file I had to restart opensips.  However, at one
point I noticed that I hand multiple opensips instances running - all
with the same cfg file, because they had not died when I exited with a
Cntrl-C.  I did kill -9 all of them before running the test below.  

 

When I set the $avp(jimmy) value it would show up as expected (with the
value I set it to), but when I changed code to NOT initialize that
particular AVP it should up with the "Old_mcDonald" value which I used
to set the $avp(bingo).  Other AVPs that I did not initialize but
printed returned a "nil" value - which is what I would have expected.

 

NOTE that in the example below (original post) that the printout
(Output) prints the value of $avp(jimmy) two times.  The first time is
before I set $avp(bingo) and the value returned is "nil".  Then I set
$avp(bingo) in Lua, but do NOT set $avp(jimmy) but the value gets
changed to the same thing as  $avp(bingo).  That is what really made me
scratch my head!

 

I am a fan of Lua and really like the concept of have the option to use
it with opensips.  I am willing to do testing and debugging, etc to help
make it rock solid.

 

Additionally there are a number of undocumented lua functions that would
be good to add to the documentation.  For example:

*	"pseudoVarSet"
*	"scriptVarGet"
*	"scriptVarSet"

 

NOTE: It would probably be good to change "pseudoVar" function name to
be "pseudoVarGet" to match "pseudoVarSet", "scriptVarGet" and
"scriptVarSet" for consistency.  :-) 

 

Thanks for help.

 

James 

 

________________________________

From: users-bounces at lists.opensips.org
[mailto:users-bounces at lists.opensips.org] On Behalf Of Razvan Crainea
Sent: Friday, June 15, 2012 2:58 AM
To: users at lists.opensips.org
Subject: Re: [OpenSIPS-Users] LUA AVP issue?

 

Hi, James!

I am not sure what exactly is the problem, but I have an assumption.
When the scenario was failing, where exactly was the $avp(jimmy) first
declared? Inside the LUA script? Is it now first declared in OpenSIPS?
Is there any chance you could reproduce this issue again in full
debugging?

Regards,



Razvan Crainea
OpenSIPS Core Developer
http://www.opensips-solutions.com

On 06/15/2012 12:30 AM, Gledhill, James wrote:

	I made a few more changes to my code and tested some more and
now the problem has gone away and I can no longer replicate it.  Perhaps
it is just something I do not fully understand about AVPs or opensips or
the lua implementation.   I was able to reproduce it 100% of the time
for a while, but now can not - strange!

	 

	Any thoughts what happened in the original post?

	 

	
________________________________


	From: users-bounces at lists.opensips.org
[mailto:users-bounces at lists.opensips.org] On Behalf Of Gledhill, James
	Sent: Thursday, June 14, 2012 3:54 PM
	To: users at lists.opensips.org
	Subject: [OpenSIPS-Users] LUA AVP issue?

	 

	I am testing the Lua module in hopes of being able to use it
more later, but am coming across some strange things.

	 

	Is this the best place to ask about it?  If not point me in the
right direction. 

	 

	AVP_set or AVP_get (in Lua module) seem to be getting data
for/from other AVP(s).

	 

	I have included enough code from opensips.cfg and the lua file
to be able to replicate this problem.  It happens 100% of the time. 

	 

	 I am using 

	*	opensips 1.8
	*	CentOS 5.8
	*	Lua 5.1.4

	 

	=============

	Opensips.cfg (partial file)

	=============

	 

	## route[INVITE] is called for all invites - simple way to test
:-)

	route[INVITE] {

	    xlog("In route_INVITE\n");

	 

	    $avp(abcde) = "bean";

	    xlog("** ** avp(abcde) = $avp(abcde)\n");

	 

	    if ( lua_exec("invite") ) {     ## call the invite method in
lua file

	        xlog("lua_exec returned TRUE\n");

	    } else {

	        xlog("lua_exec returned not true\n");

	    }

	 

	    xlog("** ** avp(jimmy) = $avp(jimmy)\n");    ## this avp is
reporting the value set in lua to another avp ... WHY?

	 

	    sl_send_reply("486", "I am not answering now!");

	    exit;

	}

	 

	 

	=============

	Lua (partial file)

	=============

	 

	function invite(param)

	    xlog("**********     --->  INVITE test from lua -- getpid ="
.. getpid() .. "\n");

	    -- AVP_get("jimmy") returns a null because it is not set -
this is expected.

	    xlog("**********     --->  INVITE test from lua --
AVP_get(jimmy) =" .. tostring(AVP_get("jimmy")) .. "\n");

	 

	    AVP_set("bingo","Old_mcDonald");

	    xlog("**********     --->  INVITE test from lua --
AVP_get(bingo) =" .. tostring(AVP_get("bingo")) .. "\n");

	    xlog("**********     --->  INVITE test from lua --
AVP_get(abcde) =" .. tostring(AVP_get("abcde")) .. "\n");

	    xlog("**********     --->  INVITE test from lua --
AVP_get(fred) =" .. tostring(AVP_get("fred")) .. "\n");

	    -- NOW ... AVP_get("jimmy")  returns "Old_mcDonald" which is
what "bingo" is set to .. WHY IS avp(jimmy) returning this?

	    xlog("**********     --->  INVITE test from lua --
AVP_get(jimmy) =" .. tostring(AVP_get("jimmy")) .. "\n");

	    xlog("**********     --->  INVITE test from lua -- filemtime
=" .. filemtime("/root/foo.dump") .. "\n");

	 

	    return 0;

	end

	 

	 

	=============

	Output

	=============

	 

	In route_INVITE

	** ** avp(abcde) = bean

	siplua: **********     --->  INVITE test from lua -- getpid
=6269

	siplua: **********     --->  INVITE test from lua --
AVP_get(jimmy) =nil

	siplua: **********     --->  INVITE test from lua --
AVP_get(bingo) =Old_mcDonald

	siplua: **********     --->  INVITE test from lua --
AVP_get(abcde) =bean

	siplua: **********     --->  INVITE test from lua --
AVP_get(fred) =nil

	siplua: **********     --->  INVITE test from lua --
AVP_get(jimmy) =Old_mcDonald   <<HOW/WHY is this getting set?>>

	siplua: **********     --->  INVITE test from lua -- filemtime
=1277825218

	lua_exec returned TRUE

	** ** avp(jimmy) = Old_mcDonald

	 

	 

	
	
	
	

	_______________________________________________
	Users mailing list
	Users at lists.opensips.org
	http://lists.opensips.org/cgi-bin/mailman/listinfo/users

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20120615/14a801b4/attachment-0001.htm>


More information about the Users mailing list