Hi,
I am using app_lua to frequently store some data in htable and avp
entries, using sr.pv.sets. When I read the values using sr.pv.get
immediately after writing them, they seem correct. However, when I read
them later from Lua, I have noticed that sometimes the value is
incorrect or nil. Am I doing something wrong?
The following code uses rtimer to duplicate the problem on startup,
printing the errors to syslog.
Tested on version: kamailio 3.3.1 (i386/linux) 2d0f6f
###############
# kamailio.cfg
###############
loadmodule "pv.so"
loadmodule "xlog.so"
loadmodule "htable.so"
loadmodule "rtimer.so"
loadmodule "app_lua"
modparam("htable", "htable", "status=>size=14;autoexpire=0;")
modparam("rtimer", "timer", "name=ta;interval=10;mode=1")
modparam("rtimer", "exec", "timer=ta;route=LUA_TEST")
# the following path may need to change depending on filesystem setup
modparam("app_lua", "load", "/etc/kamailio/kamailio.lua")
route
{
route(LUA_TEST);
}
route[LUA_TEST] {
$var(lua_test_key) = $(pp{s.toupper}) + "::";
lua_runstring("htable_test([[status=>$var(lua_test_key)]])");
lua_runstring("avp_test([[status=>$var(lua_test_key)]])");
}
----------------
-- kamailio.lua
----------------
-- Test of sr.pv operations in Lua
function htable_test (namekey)
local pvar_prefix = "$sht("..namekey
pvar_test(pvar_prefix)
end
function avp_test ( name )
local pvar_prefix = "$avp("..name
pvar_test(pvar_prefix)
end
function pvar_test ( pvar_prefix )
for value = 10000, 10050 do
local pvar = pvar_prefix..value..")"
--sr.log("info", "Lua attempting to set '"..pvar.."' to value
'"..value.."'")
sr.pv.sets(pvar, value)
end
for value = 10000, 10050 do
-- now we check what was stored
local pvar = pvar_prefix..value..")"
local checkvar = sr.pv.get(pvar)
if ( tostring(checkvar) ~= tostring(value) ) then
sr.err(string.format("CHECK: Lua checking pvar '%s' and got value
'%s' which is NOT '%s'",
tostring(pvar),
tostring(checkvar),
tostring(value)
))
end
end
end
-- end of kamailio.lua
Thanks,
-Andrew
Hello,
I'm forwarding registrations to Freeswitch and adding a Path header using add_path_received() for endpoints behind NAT. When TCP is used, this results in a header like this:
Path: <sip:a.a.a.a:5070;lr;received="sip:b.b.b.b:35430;transport=tcp">
Freeswitch doesn't like the transport protocol inside the quotations and refuses to route a call to the registered user.
Constructing the header manually without the quotes such as:
append_hf("Path: <sip:$Ri:$Rp;lr;received=sip:$si:$sp;transport=$pr>\r\n");
solves the problem.
Is there a reason for the quotes?
Best Regards,
Spencer
Hello Community,
I've recently started to use the Dialog module to manage the amount of incoming calls from our SIP provider allowed to pass through by using profiles_with_values and setting the size of these profiles to a certain amount.
Most of the time this works as it should, but sometimes the 'slots' available for a profile aren't cleared even though a dialog has finished. This seems to happen when an high amount of regular traffic is hitting kamailio.
Has anyone else experienced this? Are there perhaps any other ways to control the slots available for certain incoming SIP traffic?
Below parts of my configuration file. Perhaps I'm doing something wrong which causes this to happen.
In my route[WITHINDLG] -> loose_route -> is_method("BYE") I'm not calling dlg_manage(), could this be the problem?
Other comments are welcome too, as I'm fairly new to Kamailio.
modparam("dialog", "enable_stats", 1)
modparam("dialog", "dlg_flag", 4)
modparam("dialog", "hash_size", 4096)
modparam("dialog", "profiles_with_value", "318005004");
modparam("dialog", "default_timeout", 43200)
modparam("dialog", "dlg_match_mode",2)
modparam("dialog", "detect_spirals", 1)
request_route {
# per request initial checks
route(REQINIT);
# handle requests within SIP dialogs
route(WITHINDLG);
### only initial requests (no To tag)
# CANCEL processing
if (is_method("CANCEL"))
{
if (t_check_trans())
t_relay();
exit;
}
t_check_trans();
# record routing for dialog forming requests (in case they are routed)
# - remove preloaded route headers
remove_hf("Route");
if (is_method("INVITE")) {
xlog("L_INFO", "Incoming request for $rU from $fU");
if ($rU == "318005004") {
route(DIALOG);
}
}
# handle registrations
route(REGISTRAR);
if ($rU==$null)
{
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
exit;
}
# dispatch destinations
route(DISPATCH);
route(RELAY);
}
route[DIALOG] {
dlg_manage();
record_route();
$var(SIZE) = 0;
sql_query("vf", "exec dbo.SelectAvailableSlots '00$rU'", "ra");
$avp(s:limit) = $dbr(ra=>[0,7]);
xlog("L_INFO", "Maximum simultaneous calls is configured at $avp(s:limit) ....");
sql_result_free("ra");
if ($rU == "318005004") {
get_profile_size("318005004", "$rU", "$var(SIZE)");
}
xlog("L_INFO", "There are currently $var(SIZE) calls for $rU, excluding the current call");
if($var(SIZE) >= $avp(s:limit)) {
xlog("L_INFO", "Simultaneous calls limit of $avp(s:limit) reached for $rU: $var(SIZE)\n");
sl_send_reply("603", "Simultaneous calls limit reached");
exit;
}
if ($rU == "318005004") {
set_dlg_profile("318005004", "$rU");
}
if ($rU == "318005004") {
if(get_profile_size("318005004", "$var(SIZE)")) {
xlog("L_INFO", "There are currently $var(SIZE) calls for $rU, including the current call");
}
}
}
route[WITHINDLG] {
if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
#Used for call transfer
if($fU == "318005004") {
if (is_method("UPDATE")) {
sl_send_reply("405","Method not allowed");
xlog("L_INFO", "Dropping UPDATE message...\n");
exit;
}
if (is_method("INVITE")) {
record_route();
}
if (is_method("BYE")) {
dlg_manage();
}
}
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
}
route(RELAY);
} else {
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# non loose-route, but stateful ACK;
# must be ACK after a 487 or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction ... ignore and discard.
exit;
}
}
sl_send_reply("404","Not here");
}
exit;
}
}
Regards,
Grant
Hi,
I'm playing around with xavp, but there are some things I can't wrap my
head around.
What basically works is this:
$xavp(a=>foo) = 'foo';
$xavp(a[0]=>bar) = 'bar';
Getting the value like this:
xlog("L_INFO", "a-foo='$xavp(a=>foo)' and a-bar='$xavp(a=>bar)'");
as well as
xlog("L_INFO", "a-foo='$xavp(a[0]=>foo)' and a-bar='$xavp(a[0]=>bar)'");
... works, because when omitting the index, it assumes [0]. I really
like to avoid such implicit assumptions though, to make the config
really clear, so I prefer the second approach.
What doesn't work for me then is explicit assignment of the very first
value, like this:
$xavp(a[0]=>foo) = 'foo';
$xavp(a[0]=>bar) = 'bar';
If I do this, the "a" xavp is never created. Wouldn't it be good
practice to create the xavp on first assignment? That way, I don't have
to take care in the config file whether the xavp is used for the first
time, where I have to omit the index.
What I'm also wondering is whether it's possible to directly access
nested xavps, like this:
$xavp(a=>foo) = 'afoo';
$xavp(b=>foo) = 'bfoo';
$xavp(c=>a) = $xavp(a);
$xavp(c=>b) = $xavp(b);
xlog("L_INFO", "a-foo='$xavp(c=>a[0]=>foo)'");
or
xlog("L_INFO", "a-foo='$xavp(c=>a=>foo)'");
Both ways give me "a-foo='<<xavp:0x7f0d387fe178>>'". Is this even
intended? Would be really cool if that's possible!
Thanks,
Andreas
Hi All,
I am experiencing an issue when i try to contact xy(a)cisco.com.
I found that kamailio/sip-router can't resolve by default resolving way
a TCP + SRV records from domain cisco.com.
e.g. cisco.com
misi@alma:~$ host -t NAPTR cisco.comcisco.com has no NAPTR record
misi@alma:~$ host -t SRV _sip._udp.cisco.com
Host _sip._udp.cisco.com not found: 3(NXDOMAIN)
misi@alma:~$ host -t SRV _sip._tcp.cisco.com_sip._tcp.cisco.com has SRV record 1 0 5060 vcsgw.cisco.com.
misi@alma:~$ host -t SRV _sips._tcp.cisco.com_sips._tcp.cisco.com has SRV record 1 0 5061 vcsgw.cisco.com.
I can't call xy(a)cisco.com because it does not exists an NAPTR record in
domain cisco.com,
and furthermore no SRV with udp.
But it exists sip+tcp record
and also exists an secure sip SRV, so sips+tcp record!
I read rfc3263
I find kamailio dns resolver is not working as it should according RFC3263.
http://tools.ietf.org/html/rfc3263
_If no NAPTR records are found, the client constructs SRV queries
for those transport protocols it supports, and does a query for each._
So kamailio should query all (udp, tcp, tls, sctp whatever) protocols.
Can anyone help/guide me to create a fix to this issue?
My plan is to create a patch to kamailio resolver, to correct and behave
according RFC3263.
Any help or guidance appreciated!
Thanks,
Misi
Hello,
My setup includes a cellphone that uses Wi-Fi to hookup to the internet
with IP 192.168.1.101. Cellphone app, tries to register with VOIPSwitch
through an outbound proxy server(Kamailio + rtpproxy), which rewrites SDP
to force rtp through an rtpproxy.
I can make a call from the cellphone to a PSTN number. When the PSTN
endpoint hangs up, VOIPSwitch relays a BYE message to the proxy that looks
like :
No. Time Source Destination Protocol Info
27 18.383929 IPaddr_VoipSwitch IPaddr_proxy SIP
Request: BYE sip:1234@IPaddr_VoipSwitch
Frame 27 (420 bytes on wire, 420 bytes captured)
Ethernet II, Src: Unispher_40:b5:39 (00:90:1a:40:b5:39), Dst:
Supermic_bd:b9:bc (00:30:48:bd:b9:bc)
Internet Protocol, Src: IPaddr_VoipSwitch , Dst: IPaddr_proxy
User Datagram Protocol, Src Port: sip (5060), Dst Port: 7160 (7160)
Session Initiation Protocol
Request-Line: BYE sip:1234@IPaddr_VoipSwitch SIP/2.0
Method: BYE
[Resent Packet: False]
Message Header
Route: <sip:IPaddr_proxy:7160;lr=on;nat=yes>
CSeq: 1 BYE
Via: SIP/2.0/UDP IPaddr_VoipSwitch:5060;
branch=z9hG4bk180242100434182912333954
From: sip:5678@IPaddr_VoipSwitch;tag=18024210041929123187506289
Call-ID: LUOyIDm-ecy36NcUfj5G3v1lM6g5snkM
To: "1234"
<sip:1234@IPaddr_VoipSwitch>;tag=9XHJmiuf58vTrF7.vwflEK-G63JVPQSi
Content-Length: 0
The request URI in the above message is the IP address of VOIPSwitch
itself, which causes the proxy to forward the BYE message back to
VOIPSwitch. The cellphone never receives the BYE message and consequently
never hangs up.
Any suggestions on how i can get around this problem ?
Thanks and Regards,
Vikram.
Hello,
Kamailio SIP Server v3.3.2 stable release is out.
This is a maintenance release of the latest stable branch, 3.3, that
includes fixes since release of v3.3.1. There is no change to database
schema or configuration language structure that you have to do on
installations of v3.3.0 or v3.3.1. Deployments running previous v3.x.x
versions are strongly recommended to be upgraded to v3.3.2.
For more details about version 3.3.2 (including links and hints to
download the tarball or from GIT repository), visit:
* http://www.kamailio.org/w/2012/10/kamailio-v3-3-2-released/
RPM, Debian/Ubuntu packages will be available soon as well.
Cheers,
Daniel
--
Daniel-Constantin Mierla - http://www.asipto.comhttp://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, Berlin, Nov 5-8, 2012 - http://asipto.com/u/kat
Kamailio Advanced Training, Miami, USA, Nov 12-14, 2012 -
http://asipto.com/u/katu