Hi All,
I have an interesting use-case where I need to place a delay between
cancelling branch and retrying next one.
*Background: *
Running Kamailio 5.6.x
Kamailio routes requests via a freeswitch B2BUA server on select call flows
(where B2BUA functionality is required).
Call flow examples:
PSTN --> Kamailio --> Freeswitch --> appserver1
PSTN --> Kamailio --> Freeswitch --> appserver2
On attempt failures, a branch retry is required from appserver1 to
appserver2; however …
[View More]freeswitch B2BUA remains the same
Since Freeswitch does not quite follow the RFC 3261 timer K specifications
(should be 0 seconds for reliable transports, but FS keeps transactions for
T4 (set to 2 seconds));
I have implemented an artificial delay in failure route before retrying (as
per recommendation described here:
https://freeswitch-users.freeswitch.narkive.com/TsSye66D/482-request-merged…
)
*Script config: *
onreply_route[MANAGE_REPLY] {
xlog("L_INFO", "reply $T_reply_code received");
if (t_check_status( "1[1-9][0-9]")) {
t_reset_fr();
} else {
t_set_fr(120000);
}
}
route(NATDETECT);
#!ifdef WITH_RTPENGINE
route(RTPMANAGE);
#!endif
}
route[RELAY] {
if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {
if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");
}
if (is_method("INVITE|SUBSCRIBE|UPDATE")) {
if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");
}
if(is_method("INVITE|BYE|UPDATE|CANCEL|ACK")) {
setflag(FLT_DLGINFO);
}
if (!t_relay()) {
sl_reply_error();
}
exit;
}
route[TOCARRIER] {
process bunch of things, attach custom headers, generate request URI
t_on_failure("MANAGE_FAILURE_CARRIER");
route(RELAY);
}
failure_route[MANAGE_FAILURE_CARRIER] {
xlog("L_INFO", "reply $T_reply_code received");
if ($avp(inbound_attempt)<=1){
if ($dlg_var(b2bua)=="true"){
usleep(1900000);
}
route("TOCARRIER");
}
*Call Flows: *
The above fix works well when an explicit error reply is received back.
*error reply SIP exchange: *
SBC --> INVITE(branch0) ---> Freeswitch
SBC <-- 503 <-- Freeswitch
failure_route executed (sleep runs here)
SBC --> INVITE(branch1) ---> Freeswitch
call continues as expected.
however does not work when NO reply is received at all and the timer
expires.
*Current timer expiry SIP exchange: *
SBC --> INVITE(branch0) ---> Freeswitch
SBC <-- 100/180 <-- Freeswitch
SBC (timer expires)
failure_route executed (sleep runs here)
SBC --> INVITE(branch1) ---> Freeswitch
SBC <-- 482 Merged <-- Freeswitch
SBC --> CANCEL(branch0) ---> Freeswitch
I am looking to CANCEL branch0 before the sleep delay runs
Based on source code, t_cancel_branches("this") can only be executed in
reply_route;
however the chellenge is that reply_route never sees the "faked 408" on
timer expiry(although the failure route does see $T_reply_code 408).
Any suggestions on how to handle this would be greatly appreciated.
TIA
[View Less]
I'm looking for information on the correct way to handle calls to RTPEngine when processing in-dialog requests. I currently have several setid's configured for varying usages. During processing of an initial INVITE, a determination is made as to if the call will require the use of RTPEngine, and if so, which of the sets should be used. The following is done in code:
*
setid is assigned to AVP $avp(rtpengine_pool_num)
*
set_rtpengine_set("$avp(rtpengine_pool_num)") is called,
*
…
[View More]rtpengine_offer is then called.
*
Additionally, a record-route parameter of proxy_media=yes is added.
*
The flag PROXY_MEDIA is set
In the reply route, the PROXY_MEDIA flag is checked, and if set, set_rtpengine_set("$avp(rtpengine_pool_num)") is called, followed by rtpengine_answer.
When handling an in-dialog message my code didn't have anything to evaluate for the setid. rtpengine_offer was just called. Looking at the debug from the rtpengine module, I can see that the record is found in the hashtable, however the node indicated in that result is not necessarily used - rtpengine will select an entry from the default setid instead. From the rtpengine module logs, IP addresses redacted:
2(9) DEBUG: {time=1744651756.968228} rtpengine [rtpengine_funcs.c:139]: check_content_type(): type <application/sdp> found valid
2(9) DEBUG: {time=1744651756.968228} rtpengine [rtpengine.c:2249]: build_rtpp_socks(): same rtpengines list version: 1 (1744651613)
2(9) DEBUG: {time=1744651756.968228} rtpengine [rtpengine.c:3818]: select_rtpp_node_old(): rtpengine hash table lookup find node=udp:A.B.C.D:1234 for calllen=36 callid=ac66f56b-93f8-123e-1b99-0242ac120002 viabranch=
2(9) DEBUG: {time=1744651756.968228} rtpengine [rtpengine.c:3702]: select_rtpp_node_new(): sum is = 210
2(9) DEBUG: {time=1744651756.968228} rtpengine [rtpengine.c:3198]: rtpp_function_call(): proxy reply: d3:sdp288:v=0
o=FreeSWITCH 1744611570 1744611571 IN IP4 W.X.Y.Z
s=FreeSWITCH
c=IN IP4 W.X.Y.Z
My question is really: **SHOULD** rtpengine_offer (and rtpengine_manage, etc) use the node that it finds in the hash table lookup automatically, or should I have to explicitly set the setid? For now I've solved the problem by adding the setid to the record-route headers so I can easily retrieve it in dialog, but it seems that if the module finds a record for a node that there should be some way to rely on that explicitly.
Kaufman
Senior Voice Engineer
E: bkaufman(a)bcmone.com
SIP.US Client Support: 800.566.9810 | SIPTRUNK Client Support: 800.250.6510 | Flowroute Client Support: 855.356.9768
[img]<https://www.sip.us>
[img]<https://www.siptrunk.com>
[img]<https://www.flowroute.com>
NOTE: This e-mail and any attachments are from BCM One, Inc. and are intended solely for the use and review of the individual(s) to whom it is addressed. If you believe you received this e-mail in error, please notify the sender immediately, delete the e-mail (and any attachments) from your computer and do not copy or disclose it to anyone else.
[View Less]
Hello,
I´ve googled around about tcp timeout in kamailio tcp connections when the tcp connection is broken.
Found this old question and to me it feels like I’m having that same situation as original question https://www.mail-archive.com/sr-users@lists.kamailio.org/msg15020.html
Also found this https://kamailio.org/mailman3/hyperkitty/list/sr-dev@lists.kamailio.org/thr… and it seems to be the same description pretty much that I´m seeing.
When the tcp connection (or tls) is interrupted in the …
[View More]network it takes around 15min for kamailio to reset the outgoing tcp connection.
I see in the logs that when restarting kamailio process it logs
2025-03-27 12:25:18.697 { "level": "INFO", "module": "core", "file": "core/tcp_main.c", "line": 3282, "function": "tcp_init", "logprefix": "", "message": "Set TCP_USER_TIMEOUT=10000 ms" }
So I think the fix from this https://github.com/kamailio/kamailio/commit/d893f3af1444c8c4c5db6cd53fb5777… is applied.
This is tested with 5.8.5 and I have tested this by setting up with dispatcher tcp connection to external host
Then with iptables drop traffic to that host, waiting kamailio to notice that destination is down, removing the iptables input and it takes around 15min to recover. (also restarting the kamailio helps and resolves the connection)
And this is what kamailio prints during the test:
Apr 4 08:29:15 kamailio[156947]: { "level": "ERROR", "module": "xlog", "file": "xlog.c", "line": 278, "function": "", "logprefix": "", "message": "Destination down: OPTIONS sip:ext-host;transport=tcp (<null>)" }
Apr 4 08:44:43 kamailio[156957]: { "level": "ERROR", "module": "core", "file": "core/tcp_read.c", "line": 267, "function": "tcp_read_data", "logprefix": "", "message": "error reading: Connection timed out (110) ([]:5060 -> []:47492)" }
Apr 4 08:44:43 kamailio[156957]: { "level": "ERROR", "module": "core", "file": "core/tcp_read.c", "line": 1524, "function": "tcp_read_req", "logprefix": "", "message": "error reading - c: 0x7f8625dea9b0 r: 0x7f8625deaad8 (-1)" }
Apr 4 08:45:05 kamailio[156957]: { "level": "ERROR", "module": "xlog", "file": "xlog.c", "line": 278, "function": "", "logprefix": "Source:[ext-host]:5060, Call-id:4d0e1ccd315c817f-156947@int-host, CSeq:10", "message": "Destination up: OPTIONS sip:ext.host;transport=tcp (<null>)" }
Any advice how to lower the timeout to be quicker in such event?
-Pyry
[View Less]
Previous Thread: https://kamailio.org/mailman3/hyperkitty/list/sr-users@lists.kamailio.org/t…
Hello everyone,
Should I use a STUN server, or can I just configure NAT properly?
Here’s my current setup:
arduino
Copy
Edit
Router (NAT device)
↓
Kamailio + RTPengine machine
↓
Virtual machine running Kubernetes
↓
Asterisk container
Kamailio and RTPengine are sitting behind the NAT (the router), and they handle SIP and media. Do I need a STUN server in this case, or can I …
[View More]manage everything with NAT configuration alone?
And what is the better approach?
Any insights or best practices would be appreciated!
Thank you.
[View Less]
Hi guys,
I opened issue on github: https://github.com/kamailio/kamailio/issues/4199
- Description:
Kamailio (5.8.x): SIP proxy
FreeSWITCH: Media
- OS: Debian 12
gateway: aaaa:bbb:cccc:20::1
ipv6: aaaa:bbb:cccc:20::41e
- kamailio.cfg:
#!define ADDR_IPV4 xxx.xxx.xxx.xxx
#!define ADDR_IPV6 [aaaa:bbb:cccc:20::41e]
listen=ADDR_IPV4
listen=ADDR_IPV6
- I execute netstat -nlutp:
tcp6 0 0 aaaa:bbb:cccc:20:::5060 :::* LISTEN 1691274/kamailio
tcp6 0 …
[View More]0 aaaa:bbb:cccc:20:::5061 :::* LISTEN 1691274/kamailio
udp6 0 0 aaaa:bbb:cccc:20:::5060 :::* 1691222/kamailio
Why I set listen ip is aaaa:bbb:cccc:20::41e but kamailio stripped the last part of the address aaaa:bbb:cccc:20::
I have tried many ways but it does not work.Is there any additional configuration required regarding the Debian network interface?
- Here is interfaces(of course i can ping from/to ipv6 address):
# Additional interfaces, just in case we're using
# multiple networks
allow-hotplug eth1
iface eth1 inet6 static
address aaaa:bbb:cccc:20::41e
netmask 64
gateway aaaa:bbb:cccc:20::1
autoconf 0
Thank you.
[View Less]
Hi everyone,
I'm experiencing some issues with Kamailio and RTP Engine.
Here's the setup:
A user initiates a call, and the traffic goes through a router.
The router forwards the traffic to a machine at 192.168.1.75, which runs Kamailio and RTP Engine.
Kamailio uses a dispatcher to forward calls to 192.168.1.190, a Kubernetes node running an Asterisk container.
The problem:
When I'm inside the network, everything works fine — I can send and receive audio.
But when I'm outside the network, the …
[View More]call connects, but there's no audio in either direction (no send or receive).
Some Configs:
Kamailio.conf:
modparam("rtpengine", "rtpengine_sock", "udp:0.0.0.0:2223")
listen=udp:192.168.1.75:5060
listen=tcp:192.168.1.75:5060
listen=udp:127.0.0.1:5060
# ----- dispatcher params -----
modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
modparam("dispatcher", "flags", 2)
modparam("dispatcher", "xavp_dst", "_dsdst_")
modparam("dispatcher", "xavp_ctx", "_dsctx_")
modparam("dispatcher", "ds_ping_from", "sip:proxy@kamailio.org")
modparam("dispatcher", "ds_ping_interval", 60)
modparam("dispatcher", "ds_probing_mode", 1)
modparam("dispatcher", "ds_timer_mode", 1)
rtpengine.conf:
interface = 192.168.1.75
listen-udp = 0.0.0.0:2223
port-min = 10000
port-max = 20000
Firewall:
To Action From
-- ------ ----
22 ALLOW Anywhere
12222/udp ALLOW Anywhere
5060/udp ALLOW Anywhere
10000:20000/udp ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
12222/udp (v6) ALLOW Anywhere (v6)
5060/udp (v6) ALLOW Anywhere (v6)
10000:20000/udp (v6) ALLOW Anywhere (v6)
Also router has all this ports open
Thank you.
[View Less]