Hi
Im using LCR module and trying to handle 503/408 errors on provider to
route to a second one.
Actually im using
if(!load_gws(1, $rU, $var(caller_uri))) {
xlog("Gateways no disponibles");
sl_send_reply("500", "Server Internal Error - No gateway");
exit;
} else {
xlog("GW Seleccionado '$avp(i:709)'\n");
xlog("Dominio de destino: $dd\n");
xlog("To URI: $tu\n");
}
if(!next_gw()) {
xlog("No hay GW de Backup");
sl_send_reply("503", "Service not available - No gateway");
exit;
} else {
xlog("Enviado por primer GW\n");
xlog("ruri_user_avp: '$avp(i:500)'\n");
xlog("To URI after next_gw: $tu\n");
xlog("Request URI: $rU\n");
t_on_failure("FAILBACK");
}
failure_route[FAILBACK] {
if (t_is_canceled()) {
exit;
}
if (t_check_status("408|50[34]")) {
route(LCR_OUT_OP2);
}
}
And using for OP2 same routing block with id=3...
This second providers use AUTH so using:
t_on_failure("TRUNKAUTH");
failure_route[TRUNKAUTH] {
if (t_is_canceled()) {
exit;
}
if(t_check_status("401|407")) {
if (to_gw("3")) {
xlog("Autenticación ");
$avp(auser) = "user";
$avp(apass) = "pass";
}
uac_auth();
t_relay();
exit;
}
But getting this error:
May 30 09:59:05 kamailio /usr/local/sbin/kamailio[21602]: ERROR: tm
[t_fwd.c:1704]: t_forward_nonack(): ERROR: t_forward_nonack: no branches
for forwarding
May 30 09:59:05 kamailio /usr/local/sbin/kamailio[21602]: ERROR: tm
[tm.c:1466]: _w_t_relay_to(): ERROR: w_t_relay_to: t_relay_to failed
Any idea how to resolve that?
In Kamailio 4.2, I’m having problems converting an AVP integer value into a string.
My Kamailio config stores the return code from auth_check() and outputs it.
$avp(auth_code) = auth_check("$fd", "subscriber", "1");
xlog("L_NOTICE", “response = $avp(auth_code)”);
When I check the AVP against an integer, it behaves normally. However, I cannot convert it to a string. The return value -3 (invalid user) gets converted to the string “18446744073709551613” when outputting it.
My hunch is that Kamailio is treating the AVP as an unsigned integer (rather than a signed integer) when it converts it to a string. If I try this with an AVP with a positive integer, it works as expected.
Can someone tell me how to convert a negative integer into a string in Kamailio?
-H
Hi List,
I'm trying to have an external application to write CDR to a database by
doing this:
event_route[dialog:start] {
evapi_relay("{'cdr_id':* $dlg_var(cdr_id),* 'event': 'answered'}");
}
event_route[dialog:end] {
evapi_relay("{'cdr_id': *$dlg_var(cdr_id)*, 'event': 'ended'}");
}
event_route[dialog:failed] {
evapi_relay("{'cdr_id': *$dlg_var(cdr_id)*, 'event': 'failed'}");
}
$dlg_var(cdr_id) is set inside a request route. However, in these event
routes, its value is always null. Its seems that $dlg_var variables are not
available in those event routes.
What are the variables available in dialog event route? Any suggestion on
how to achieve what I'm trying to do?
Best regards,
Minh
Hi,
Has anyone experienced segfault using http_async_query from
http_async_client module? Here is BT:
#0 __GI_fgets_unlocked (buf=0x7fca23ffe660 "127.0.0.1", n=n@entry=1032,
fp=0x7fca23ffe660) at iofgets_u.c:53
53 iofgets_u.c: No such file or directory.
(gdb) bt
#0 __GI_fgets_unlocked (buf=0x7fca23ffe660 "127.0.0.1", n=n@entry=1032,
fp=0x7fca23ffe660) at iofgets_u.c:53
#1 0x00007fca68f08afa in get_contents (stream=<optimized out>, len=1032,
linebuf=0x7fca23ffe660 "127.0.0.1") at nss_files/files-XXX.c:201
#2 internal_getent (result=0x7fca23ffe5c0, buffer=buffer@entry=0x7fca23ffe640
"\177", buflen=buflen@entry=1064, errnop=errnop@entry=0x7fca23ffebb0,
herrnop=herrnop@entry=0x7fca23ffec00, af=af@entry=0,
flags=flags@entry=0) at nss_files/files-XXX.c:246
#3 0x00007fca68f09ca3 in _nss_files_gethostbyname4_r
(name=name@entry=0x7fca2e790fa0
"localhost", pat=pat@entry=0x7fca23ffebe0, buffer=buffer@entry=0x7fca23ffe640
"\177", buflen=buflen@entry=1064,
errnop=errnop@entry=0x7fca23ffebb0, herrnop=herrnop@entry=0x7fca23ffec00,
ttlp=ttlp@entry=0x0) at nss_files/files-hosts.c:402
#4 0x00007fca79eb7757 in gaih_inet (name=<optimized out>,
name@entry=0x7fca2e790fa0
"localhost", service=<optimized out>, req=req@entry=0x7fca341c7490,
pai=pai@entry=0x7fca23ffed10,
naddrs=naddrs@entry=0x7fca23ffed00) at
../sysdeps/posix/getaddrinfo.c:850
#5 0x00007fca79ebae0d in __GI_getaddrinfo (name=0x7fca2e790fa0
"localhost", service=0x7fca23ffeec0 "18000", hints=0x7fca341c7490,
pai=0x7fca23ffee78) at ../sysdeps/posix/getaddrinfo.c:2406
#6 0x00007fca6e0f80f4 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#7 0x00007fca6e104fa4 in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#8 0x00007fca6e10284b in ?? () from /usr/lib/x86_64-linux-gnu/libcurl.so.4
#9 0x00007fca723c9182 in start_thread (arg=0x7fca23fff700) at
pthread_create.c:312
#10 0x00007fca79ee547d in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:111
Camille, are you maintaining this module now?
Hi All,
I've been doing some work this week with the new http_async_client module,
it seems that with it's default behaviour it's not possible to execute
another async query in the block immediately following the response, for
example the following config:
request_route {
if (!t_newtran()) {
sl_reply_error();
exit();
}
http_async_query("http://localhost:8090/req_1", '{"user":"$fU"}',
"REQ_1");
}
route[REQ_1] {
xlog("L_INFO", "route[REQ_1]: INIT\n");
if ($http_ok) {
xlog("L_INFO", "route[REQ_1]: status $http_rs\n");
xlog("L_INFO", "route[REQ_1]: Sending REQ_2\n");
http_async_query("http://localhost:8090/req_2", '{"user":"$fU"}',
"REQ_2");
} else {
xlog("L_INFO", "route[REQ_1]: error $http_err)\n");
}
}
route[REQ_2] {
xlog("L_INFO", "route[REQ_2]: INIT\n");
if ($http_ok) {
xlog("L_INFO", "route[REQ_2]: status $http_rs\n");
} else {
xlog("L_INFO", "route[REQ_2]: error $http_err)\n");
}
}
Generates the following error:
10(11832) INFO: <script>: route[REQ_1]: INIT
10(11832) INFO: <script>: route[REQ_1]: status 200
10(11832) INFO: <script>: route[REQ_1]: Sending REQ_2
10(11832) WARNING: tm [t_suspend.c:186]: t_continue(): transaction is not
suspended [53195:560306836]
Looking at the source, http_async_client calls t_suspend, then goes away
and performs the request in the background. On response it calls t_continue
and then this block
<https://github.com/kamailio/kamailio/blob/4.4/modules/tm/t_suspend.c#L270-L…>
in t_continue will continue execution, the second query will cause
http_async_client to call t_suspend whilst sill executing from
the previous t_continue. Once they query is sent, the first t_continue will
complete, removing the T_ASYNC_SUSPENDED flag. When the second query
returns it doesn't find the flag and so fails as shown.
I'm far from an expect on this so would really appreciate some pointers, it
seems to fundamental to be a race condition in tm but the usage in
http_async_client seems to match usage in other modules so I'm not sure on
the best tactic.
I've tried peppering append_branch and async_route call's in various places
to no avail.
Full debug log here: http://pastebin.com/raw/rFmm0fmf
Any help appreciated,
*Thom Seddon*
Hi,
I am trying to read username portion of Contact header:
My Contact header content has a URI value such as: sip:8131110000@10.10.10.10.:5060
and I am trying to read : 8131110000
I tried the following perl similar RE and it didn't work:
($var(main_number2)) = $ct =~ /sip:(.*)@/;
Thanks,AS
Hi,
we have a machine running 16 Kamailio instances, and while upgrading
to 4.4.1 (from 4.3.5), 8 of them wouldn't start. When downgrading to
4.3.5, they all start again.
All of them have pretty identical configuration files, except IPs,
ports and some code enabled or disabled via defines. After comparing a
working and non-working configuration and adjusting setting by
setting, we finally ended up with a working configuration. The
difference is, that it won't start when a part of the code DOES NOT
get included. If it gets included, it will start.
This is the mentioned part of our main route:
#!ifdef ENABLE_INV_RATELIMIT
# Check for INVITE limit
if (is_method("INVITE") && $au == $null && !($ua =~
"sipgate") ) {
$var(invcount) = $shtcn(invcount=>%~$fU);
xlog("L_INFO", "INVITE Requests from $fU in
last 30 seconds: $var(invcount)\n");
if ($var(invcount) < 12) {
$var(uniqcid) = $ci + $Ts + $ft;
$var(tkey) = $fU + '-' +
$(var(uniqcid){s.md5}{s.substr,0,10});
$sht(invcount=>$(var(tkey))) = 1;
$var(uniqcid) = $null;
$var(tkey) = $null;
}
if ($var(invcount) > 10) {
if ($var(invcount) == 11 ) {
xlog("L_NOTICE", "User $fU
($var(domain2use)) over ratelimit for new calls, rejecting.\n");
}
# Enable this only after evaluating the impact!
append_to_reply("Retry-After: 30\r\n");
sl_send_reply("503", "Call Rate Limit
Exceeded");
exit;
}
}
#!endif
If we put this line at the top of the configuration file, everything works:
#!define ENABLE_INV_RATELIMIT
If we delete this line, startup does not work. It just sits in ps for
one minute without forking, and then gets terminated.
We enabled a bit of debugging, and this is apparently the error
causing Kamailio to shutdown:
May 25 14:50:15 kammel /usr/sbin/kamailio[24989]: DEBUG: <core>
[sr_module.c:920]: init_mod_child(): rank 53: nathelper
May 25 14:50:15 kammel /usr/sbin/kamailio[24987]: DEBUG: <core>
[local_timer.c:61]: init_local_timer(): timer_list between 0x9f0428
and 0xa34428
May 25 14:50:15 kammel /usr/sbin/kamailio[24987]: DEBUG: <core>
[io_wait.h:376]: io_watch_add(): DBG: io_watch_add(0x9f0240, 82, 1,
(nil)), fd_no=0
May 25 14:50:15 kammel /usr/sbin/kamailio[24987]: ERROR: <core>
[io_wait.h:459]: io_watch_add(): epoll_ctl failed: Bad file descriptor
[9]
May 25 14:50:15 kammel /usr/sbin/kamailio[24987]: CRITICAL: <core>
[tcp_read.c:1747]: tcp_receive_loop(): failed to add tcp main socket
to the fd list
May 25 14:50:15 kammel /usr/sbin/kamailio[24987]: CRITICAL: <core>
[tcp_read.c:1815]: tcp_receive_loop(): exiting...
I have no idea, how this part of the code could lead to this error,
but it is reproducable, that at least on this system setting or
disabling this define fixes or breaks the startup.
Does anybody have an idea, what's happening there?
Best Regards,
Sebastian
Hi Folks,
I am looking for a solution to do the following, basically an SBC-like solution.
I have an internal asterisk system that should make outbound calls towards a provider, but that provider authenticates the customer based on IP address. And I have many such customers. The provider is not willing to make changes to his practice...
Asterisk is bound to a single IP, so there is not much I can do.
I was thinking about creating several outbound accounts for asterisk, and then a multi-homed Kamailio would do the following:
If request comes from user1, Kamailio would send the request to the provider from IP1.
If request comes from user2, Kamailio would send the request to the provider from IP2.
And so on, for as many IPs as many customers I want to handle.
Is there a more elegant way to do this?
If not, how should I implement this?
Thanks in advance,
Attila
Good morning list,
I need to ask you a question about a problem we are fighting on our VoIP
platform based on Kamailio 4.3.5.
Our platform is made by more nodes over Europe countries, and we are
encountering a problem with the size of the SIP package which, exceeds
the physiological limit of about 1350 bytes.
The real problem is caused from Via: Header (inside the SIP packet)
which is added to each element of the system for transit on the call.
>From what we have analyzed, the problem is not so much due to the number
of entered Via: records but, by the fact that they contain a branch
parameter extremely long.
Here the call flow example from CARRIER A —> Kamailio1 —> Kamailio2 —>
CARRIER B
Extract from SIP message sent from CARRIER A to K1
INVITE sip:999912341234@192.168.158.42 SIP/2.0.
Via: SIP/2.0/UDP 192.168.220.141:5060;branch=z9hG4bK49e4301c;rport.
Extract from SIP message sent from K1 to K2
INVITE sip:999912341234@192.168.127.244 SIP/2.0.
Record-Route: <sip:192.168.158.42;lr;did=194.a0f1;nat=yes>.
Via: SIP/2.0/UDP
192.168.158.42;branch=z9hG4bK0635.7c1e97c2d5c01ea98e8d0e7fa23a3822.0.
Via: SIP/2.0/UDP
192.168.158.42;branch=z9hG4bKsr-j4IPOlV7MGQKatycM.cuOBV4OBVLMGZfWxF-W.y6Mx1LgRWIC9gIgx4fzxj7MBP7MBVAOBF4M.1jmxuqC93X3heroEWvH9vsCFN43qd4zRj4Mlyf3l1LNSQLpx4uMx3A.
Extract from SIP message sent from K2 to CARRIER B
INVITE sip:999912341234@192.168.65.248 SIP/2.0.
Record-Route: <sip:192.168.127.244;lr;did=194.5122;nat=yes>.
Via: SIP/2.0/UDP
192.168.127.244;branch=z9hG4bK0635.f843472880b380acde3a33732975fde9.0.
Via: SIP/2.0/UDP
192.168.127.244;branch=z9hG4bKsr-j4IPOlV7MGQKatycW.F7MBj4OBFuzGZ4MB1LNSQLpx4uMx3AzuaVHRaYpB1JNEt736cQkBIvalaJmly6Mlj7W6Mfg.qw3leqWRMAMRKrz.rIzSPAg.pE3.Vl3.MZMBV7My**.
Via: SIP/2.0/UDP
192.168.127.244;branch=z9hG4bKsr-j4IPOlV7MGQKatycW.F7MBj4OBFuzGZ4MB1JNEt736cQkBIvalaJmwWLORv4mK0Hot3w.jpam6t4kRWWOEWu.4eRWFQGKqfWauYEKwrSOKN7k.gWkxtMgue9mjMsg4IhkxaEkhrbW4uGjxpWPIg0.4eSWF47MRY1kUKfPlqlRxWvg9e5aKp6mxI6N4WS.BPlNRP4kIebWFudkR3loxtM.IWa.U0ZWUKWkxW0.
Is there anyone here with the idea how to solve this problem ?
Best regards