Hello,
I am using exact same logic for which is define in this documentation and single device its working fine. https://www.kamailio.org/events/2015-KamailioWorld/Day2/20-Federico.Cabiddu-...
But seems like if multiple registration with same extension, like if extension 102 logged in mobile as well web. If web device registered and mobile is not registered with wss, then the Current transaction is not going to suspend due to its consider like there is only one location entry on location table.so only one Invite send to web and mobile its going to send notification but never get Invite, even it is going to register using push notification.
So below LOCATION function should be called and sending invite to registered extension and should be waiting for Other device as well. But in my case its consider like only one device is there and transaction is not suspending.
Could you check and suggest me which part of code need to improve to so i can make it working with registered device with parallel forking for adding new branch.
Here is my code.
modparam("registrar", "max_contacts", 10) modparam("registrar", "append_branches", 1) modparam("registrar", "use_path", 1) modparam("registrar", "path_mode", 1)
loadmodule "tsilo.so" modparam("tsilo", "use_domain", 1)
modparam("htable", "htable", "vtp=>size=100;autoexpire=30;")
# append branches or resume the transaction route[PUSHJOIN] { $var(hjoin) = 0; lock("$tU"); $var(hjoin) = $sht(vtp=>join::$tU); $var(hstored) = $sht(vtp=>stored::$tU); $sht(vtp=>join::$tU) = $null; unlock("$tU"); if ($var(hjoin)==0) { if ($var(hstored)) ts_append("location", "$tU"); return; } $var(id_index) = $(var(hjoin){s.select,0,:}{s.int}); $var(id_label) = $(var(hjoin){s.select,1,:}{s.int}); t_continue("$var(id_index)", "$var(id_label)", "INVRESUME"); }
# lookup and relay after resuming transaction route[INVRESUME] { lookup("location"); xlog("L_INFO","[RESUME] rm=$rm ru=$ru du=$du \n"); t_relay(); ts_store(); $sht(vtp=>stored::$rU) = 1; $sht(vtp=>id_index::$tu) = $null; $sht(vtp=>id_label::$tu) = $null; xlog("L_INFO","stored transaction [$T(id_index):$T(id_label)] $fU => $rU\n"); }
route[SUSPEND] { if ( !t_suspend() ) { xlog("L_ERROR","[SUSPEND] failed suspending trasaction [$T(id_index):$T(id_label)]\n"); send_reply("501", "Suspending error"); exit; } xlog("L_INFO","[SUSPEND] suspended transaction [$T(id_index):$T(id_label)] $fU=> $rU\n"); $sht(vtp=>join::$rU) = "" + $T(id_index) + ":" + $T(id_label); xlog("L_INFO","htable key value [$sht(vtp=>join::$rU)]\n"); }
route[SENDPUSH] { $avp(platform) = $hdr(X-pn-platform); $var(headers) = "Content-Type: application/json\r\nAuthorization: Bearer 55466cc-c789-4a48-39c8-219ebaa1512f"; $var(body) = "{"user": "" + $rU + "", " + ""platform": "" + $avp(platform) + ""}"; http_client_query("https://handlepush.xxx.com/v2/phone/call/send_notification_kamalio", "$var(body)", "$var(headers)", "$var(res)");
}
# User location service route[LOCATION] {
if (!lookup("location")) { send_reply("100", "Trying"); xlog("L_INFO","SUSPENDING TRANASACTION $fU => $rU\n"); route(SUSPEND); } else { t_relay(); ts_store(); $sht(vtp=>stored::$rU) = 1; xlog("L_INFO","stored transaction [$T(id_index):$T(id_label)] $fU=> $rU\n"); } route(SENDPUSH); exit; }
if (is_method("REGISTER") || from_uri==myself) { xlog("L_INFO", "SAVING TO LOCATIONS $si:$sp\n"); if (!save("location")) { sl_reply_error(); } route(PUSHJOIN); exit; }
Can you help me to understand why parallel forking not working in this case ?
Thanks
Hi, which version of kamailio are you running? According to your description it looks like appending new branch after register it's not working (the call to ts_append). Can you try to add some logs in the script around that line and run kamailio with debug level 3? Then you can share the logs using something like pastebin and I'll have a look.
Regards,
Federico
On Thu, May 8, 2025, 13:35 bhavikpatel14388--- via sr-dev < sr-dev@lists.kamailio.org> wrote:
Hello,
I am using exact same logic for which is define in this documentation and single device its working fine.
https://www.kamailio.org/events/2015-KamailioWorld/Day2/20-Federico.Cabiddu-...
But seems like if multiple registration with same extension, like if extension 102 logged in mobile as well web. If web device registered and mobile is not registered with wss, then the Current transaction is not going to suspend due to its consider like there is only one location entry on location table.so only one Invite send to web and mobile its going to send notification but never get Invite, even it is going to register using push notification.
So below LOCATION function should be called and sending invite to registered extension and should be waiting for Other device as well. But in my case its consider like only one device is there and transaction is not suspending.
Could you check and suggest me which part of code need to improve to so i can make it working with registered device with parallel forking for adding new branch.
Here is my code.
modparam("registrar", "max_contacts", 10) modparam("registrar", "append_branches", 1) modparam("registrar", "use_path", 1) modparam("registrar", "path_mode", 1)
loadmodule "tsilo.so" modparam("tsilo", "use_domain", 1)
modparam("htable", "htable", "vtp=>size=100;autoexpire=30;")
# append branches or resume the transaction route[PUSHJOIN] { $var(hjoin) = 0; lock("$tU"); $var(hjoin) = $sht(vtp=>join::$tU); $var(hstored) = $sht(vtp=>stored::$tU); $sht(vtp=>join::$tU) = $null; unlock("$tU"); if ($var(hjoin)==0) { if ($var(hstored)) ts_append("location", "$tU"); return; } $var(id_index) = $(var(hjoin){s.select,0,:}{s.int}); $var(id_label) = $(var(hjoin){s.select,1,:}{s.int}); t_continue("$var(id_index)", "$var(id_label)", "INVRESUME"); }
# lookup and relay after resuming transaction route[INVRESUME] { lookup("location"); xlog("L_INFO","[RESUME] rm=$rm ru=$ru du=$du \n"); t_relay(); ts_store(); $sht(vtp=>stored::$rU) = 1; $sht(vtp=>id_index::$tu) = $null; $sht(vtp=>id_label::$tu) = $null; xlog("L_INFO","stored transaction [$T(id_index):$T(id_label)] $fU => $rU\n"); }
route[SUSPEND] { if ( !t_suspend() ) { xlog("L_ERROR","[SUSPEND] failed suspending trasaction [$T(id_index):$T(id_label)]\n"); send_reply("501", "Suspending error"); exit; } xlog("L_INFO","[SUSPEND] suspended transaction [$T(id_index):$T(id_label)] $fU=> $rU\n"); $sht(vtp=>join::$rU) = "" + $T(id_index) + ":" + $T(id_label); xlog("L_INFO","htable key value [$sht(vtp=>join::$rU)]\n"); }
route[SENDPUSH] { $avp(platform) = $hdr(X-pn-platform); $var(headers) = "Content-Type: application/json\r\nAuthorization: Bearer 55466cc-c789-4a48-39c8-219ebaa1512f"; $var(body) = "{"user": "" + $rU + "", " + ""platform": "" + $avp(platform) + ""}"; http_client_query(" https://handlepush.xxx.com/v2/phone/call/send_notification_kamalio", "$var(body)", "$var(headers)", "$var(res)");
}
# User location service route[LOCATION] {
if (!lookup("location")) { send_reply("100", "Trying"); xlog("L_INFO","SUSPENDING TRANASACTION $fU => $rU\n"); route(SUSPEND); } else { t_relay(); ts_store(); $sht(vtp=>stored::$rU) = 1; xlog("L_INFO","stored transaction [$T(id_index):$T(id_label)]
$fU=> $rU\n"); } route(SENDPUSH); exit; }
if (is_method("REGISTER") || from_uri==myself) { xlog("L_INFO", "SAVING TO LOCATIONS $si:$sp\n"); if (!save("location")) { sl_reply_error(); } route(PUSHJOIN); exit; }
Can you help me to understand why parallel forking not working in this case ?
Thanks _______________________________________________ Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org To unsubscribe send an email to sr-dev-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Hello,
Thanks for the reply.
Version: kamailio 5.8.5 (x86_64/linux) fddfbd
Here is the Push Join Updated Code.
route[PUSHJOIN] { xlog("L_WARN", "PUSHJOIN Function Called value is tU : $tU\n"); xlog("L_WARN", "PUSHJOIN Function Called value is tu : $tu\n");
# $var(ct_uri) = $(ct{re.subst,/<([^>]*)>.*/\1/}); # xlog("L_INFO", "PUSHJOIN Function Called value Contact URI: $var(ct_uri)\n");
$var(hjoin) = 0; lock("$tU"); $var(hjoin) = $sht(vtp=>join::$tU); $var(hstored) = $sht(vtp=>stored::$tU);
xlog("L_WARN", "hjoin outside If : $var(hjoin)\n"); xlog("L_WARN", "hstored outside If : $var(hstored)\n");
$sht(vtp=>join::$tU) = $null; unlock("$tU"); if ($var(hjoin)==0) { xlog("L_WARN", "hjoin INSIDE If of hjoin: $var(hjoin)\n"); xlog("L_WARN", "hstored INSIDE If of hjoin: $var(hstored)\n"); if ($var(hstored)){ xlog("L_WARN", "ts_append Function called here if this link executing...\n"); ts_append("location", "$tu"); xlog("L_WARN", "ts_append Function executed check if any error in above line...\n"); } return; } $var(id_index) = $(var(hjoin){s.select,0,:}{s.int}); $var(id_label) = $(var(hjoin){s.select,1,:}{s.int}); xlog("L_INFO","resuming trasaction [$var(id_index):$var(id_label)] $ru ($var(hjoin))\n"); t_continue("$var(id_index)", "$var(id_label)", "INVRESUME"); }
After kamailio in debug mode -3 getting below lines,
May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: WARNING: ts_append Function called here if this link executing... May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: DEBUG: tsilo [ts_append.c:76]: ts_append(): no record for sip:102@91b08a80-99c3-11ea-a870-9138eeb61ce2.com May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: WARNING: ts_append Function executed check if any error in above line...
Username is 102 just before registred on android device and domain name which is multi-tenent in freeswitch side also have it available in domain table. so what should be the value of ts_append function second argument so it consider like contact of the user exists and send call to them.
Also attached debug logs, My call schenario is dialing from 201 to 102 (while 102 is registered on Web and Mobile) Web getting INVITE but not Android APP side.
DEBUG LOGS : https://pastebin.com/2LDj27qR
Thanks in advanced.
Hi, logs cannot be accessed (I get a 404). I have a question: is the To domain different according to whether a user registers on web or on mobile? If yes you should set the use_domain parameter to 0 ( https://kamailio.org/docs/modules/5.8.x/modules/tsilo.html#tsilo.p.use_domai... ).
Regards,
Federico
On Mon, May 12, 2025 at 1:24 PM Roman Dcoz via sr-dev < sr-dev@lists.kamailio.org> wrote:
Hello,
Thanks for the reply.
Version: kamailio 5.8.5 (x86_64/linux) fddfbd
Here is the Push Join Updated Code.
route[PUSHJOIN] { xlog("L_WARN", "PUSHJOIN Function Called value is tU : $tU\n"); xlog("L_WARN", "PUSHJOIN Function Called value is tu : $tu\n");
# $var(ct_uri) = $(ct{re.subst,/<([^>]*)>.*/\1/}); # xlog("L_INFO", "PUSHJOIN Function Called value Contact URI:
$var(ct_uri)\n");
$var(hjoin) = 0; lock("$tU"); $var(hjoin) = $sht(vtp=>join::$tU); $var(hstored) = $sht(vtp=>stored::$tU); xlog("L_WARN", "hjoin outside If : $var(hjoin)\n"); xlog("L_WARN", "hstored outside If : $var(hstored)\n"); $sht(vtp=>join::$tU) = $null; unlock("$tU"); if ($var(hjoin)==0) { xlog("L_WARN", "hjoin INSIDE If of hjoin: $var(hjoin)\n"); xlog("L_WARN", "hstored INSIDE If of hjoin: $var(hstored)\n"); if ($var(hstored)){ xlog("L_WARN", "ts_append Function called here if this link
executing...\n"); ts_append("location", "$tu"); xlog("L_WARN", "ts_append Function executed check if any error in above line...\n"); } return; } $var(id_index) = $(var(hjoin){s.select,0,:}{s.int}); $var(id_label) = $(var(hjoin){s.select,1,:}{s.int}); xlog("L_INFO","resuming trasaction [$var(id_index):$var(id_label)] $ru ($var(hjoin))\n"); t_continue("$var(id_index)", "$var(id_label)", "INVRESUME"); }
After kamailio in debug mode -3 getting below lines,
May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: WARNING: ts_append Function called here if this link executing... May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: DEBUG: tsilo [ts_append.c:76]: ts_append(): no record for sip:102@91b08a80-99c3-11ea-a870-9138eeb61ce2.com May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: WARNING: ts_append Function executed check if any error in above line...
Username is 102 just before registred on android device and domain name which is multi-tenent in freeswitch side also have it available in domain table. so what should be the value of ts_append function second argument so it consider like contact of the user exists and send call to them.
Also attached debug logs, My call schenario is dialing from 201 to 102 (while 102 is registered on Web and Mobile) Web getting INVITE but not Android APP side.
DEBUG LOGS : https://pastebin.com/2LDj27qR
Thanks in advanced. _______________________________________________ Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org To unsubscribe send an email to sr-dev-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
No there is no much difference between web and mobile registration.I already tried with use_domain to 0.
modparam("tsilo", "use_domain", 0)
My only concern what value in ts_append() function second argument as if We use $tU. which means username, which send error below.
May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: WARNING: hjoin INSIDE If of hjoin: 0 May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: WARNING: hstored INSIDE If of hjoin: 1 May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: WARNING: ts_append Function called here if this link executing... May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: DEBUG: <core> [core/parser/parse_uri.c:1366]: parse_uri(): uri too short: <102> (3) May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: ERROR: tsilo [tsilo.c:200]: ts_check_uri(): bad uri [102] May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: WARNING: ts_append Function executed check if any error in above line...
And if i use $tu then not able to connect to user.Here is the below log based on $tu.
May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: WARNING: ts_append Function called here if this link executing... May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: DEBUG: tsilo [ts_append.c:76]: ts_append(): no record for sip:102@91b08a80-99c3-11ea-a870-9138eeb61ce2.com May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: WARNING: ts_append Function executed check if any error in above line...
Hi, at this point I would need the full debug logs to understand what's going on with ts_store/ts_append.
Regards,
Federico
On Tue, May 13, 2025 at 10:40 AM Roman Dcoz via sr-dev < sr-dev@lists.kamailio.org> wrote:
No there is no much difference between web and mobile registration.I already tried with use_domain to 0.
modparam("tsilo", "use_domain", 0)
My only concern what value in ts_append() function second argument as if We use $tU. which means username, which send error below.
May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: WARNING: hjoin INSIDE If of hjoin: 0 May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: WARNING: hstored INSIDE If of hjoin: 1 May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: WARNING: ts_append Function called here if this link executing... May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: DEBUG: <core> [core/parser/parse_uri.c:1366]: parse_uri(): uri too short: <102> (3) May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: ERROR: tsilo [tsilo.c:200]: ts_check_uri(): bad uri [102] May 12 14:26:02 ip-172-31-5-37 /usr/local/sbin/kamailio[1022077]: WARNING: ts_append Function executed check if any error in above line...
And if i use $tu then not able to connect to user.Here is the below log based on $tu.
May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: WARNING: ts_append Function called here if this link executing... May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: DEBUG: tsilo [ts_append.c:76]: ts_append(): no record for sip:102@91b08a80-99c3-11ea-a870-9138eeb61ce2.com May 12 11:05:35 ip-172-31-5-37 /usr/local/sbin/kamailio[1018716]: WARNING: ts_append Function executed check if any error in above line... _______________________________________________ Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org To unsubscribe send an email to sr-dev-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Hello federico,
I tried another way and manage to work around using ts_append_by_contact function.
$var(formatted_ct) = $(ct{nameaddr.uri}); ts_append_by_contact("location", "$tu", "$var(formatted_ct)");
Thank you for your support.
Thank you for sharing the solution you've found :)
Cheers,
Federico
On Fri, May 16, 2025 at 7:28 AM Roman Dcoz via sr-dev < sr-dev@lists.kamailio.org> wrote:
Hello federico,
I tried another way and manage to work around using ts_append_by_contact function.
$var(formatted_ct) = $(ct{nameaddr.uri}); ts_append_by_contact("location", "$tu", "$var(formatted_ct)");
Thank you for your support. _______________________________________________ Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org To unsubscribe send an email to sr-dev-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Hello Federico,
Late registration is working fine but some of the devices which getting below errors.
2025-05-20T12:50:16.200627+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: INFO: MOBILE Request body : {"teamBotId":"68deef60-2790-11f0-8239-2751088a5e3b"} PlatFrom : android 2025-05-20T12:50:16.360379+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: INFO: SAVING TO LOCATIONS 65.XX.10.XX:48846 2025-05-20T12:50:16.360508+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: WARNING: ts_append Function called here if this link executing... 2025-05-20T12:50:16.360569+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: <core> [core/dset.c:476]: append_branch(): max nr of branches exceeded 2025-05-20T12:50:16.360605+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: registrar [lookup.c:575]: lookup_helper(): failed to append a branch 2025-05-20T12:50:16.360639+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: <core> [core/dset.c:476]: append_branch(): max nr of branches exceeded 2025-05-20T12:50:16.360674+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: registrar [lookup.c:575]: lookup_helper(): failed to append a branch 2025-05-20T12:50:16.360711+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: <core> [core/dset.c:476]: append_branch(): max nr of branches exceeded 2025-05-20T12:50:16.360745+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: registrar [lookup.c:575]: lookup_helper(): failed to append a branch 2025-05-20T12:50:16.360779+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: <core> [core/dset.c:476]: append_branch(): max nr of branches exceeded 2025-05-20T12:50:16.360814+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: registrar [lookup.c:575]: lookup_helper(): failed to append a branch 2025-05-20T12:50:16.360847+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: <core> [core/dset.c:476]: append_branch(): max nr of branches exceeded 2025-05-20T12:50:16.360876+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: registrar [lookup.c:575]: lookup_helper(): failed to append a branch 2025-05-20T12:50:16.360922+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: <core> [core/dset.c:476]: append_branch(): max nr of branches exceeded 2025-05-20T12:50:16.360968+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: registrar [lookup.c:575]: lookup_helper(): failed to append a branch 2025-05-20T12:50:16.361012+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: <core> [core/dset.c:476]: append_branch(): max nr of branches exceeded 2025-05-20T12:50:16.361055+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: registrar [lookup.c:575]: lookup_helper(): failed to append a branch 2025-05-20T12:50:16.361091+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: <core> [core/dset.c:476]: append_branch(): max nr of branches exceeded 2025-05-20T12:50:16.361139+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: registrar [lookup.c:575]: lookup_helper(): failed to append a branch 2025-05-20T12:50:16.361185+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: <core> [core/dset.c:476]: append_branch(): max nr of branches exceeded 2025-05-20T12:50:16.361227+00:00 ip-XXX-31-29-XX /usr/local/sbin/kamailio[24050]: ERROR: registrar [lookup.c:575]: lookup_helper(): failed to append a branch 2025-05-20T12:50:16.362227+00:00 ip-172-31-29-68 /usr/local/sbin/kamailio[24050]: ERROR: tm [t_append_branches.c:208]: t_append_branches(): failure to add branches (-1)
Above error we are facing for some of the devices. Its Android device, should we need to consider as error OR Ignore ?
Can you tell me on which case is this error occurs ?