Currently (AFAIK), restarting Kamailio amidst production call processing
is basically "safe"; except for no availability during the few seconds
it takes to restart (which will just result in retransmissions until it
is available), most things will happen "correctly" after restart even
though TM state has been lost:
(1) Initial requests will be routed as initial requests always were;
(2) In-dialog requests will be loose-routed as sequential requests
always were;
(3) Replies to open transactions will fall back to stateless routing but
will be delivered correctly to their destinations based on SIP
fundamentals (i.e. Via).
(4) rtpproxy & rtpengine control messages are grouped by Call-ID, so
also stateless. If the proper destroy/remove functions are not called
from failure_route[] due to lack of TM state, it's not so bad; rtpproxy
& rtpengine will see an RTP timeout after a while and expire the
bindings on their own.
If dialog state is used, it will be lost, but assuming one is willing to
live with that, it's okay. I don't know if there has been any work done
to create a persistence layer for dialog that can be re-read completely
on startup, and if it actually works - does it? - but it's a relatively
small price to pay if it's important to integrate a change into
production in the middle of the day.
The one exception is CANCEL handling. CANCEL is a special animal, since
it's a hop-by-hop (branch-level) request, so CANCELs sent from a caller
apply to the 'caller -> Kamailio' branch. Kamailio generates separate
CANCELs endogenously for one or more 'Kamailio -> gateway' branches.
Stateful CANCEL handling with TM is implemented using t_check_trans() or
t_relay_cancel(). For example, in the stock config[1]
# CANCEL processing
if (is_method("CANCEL")) {
if (t_check_trans()) {
route(RELAY);
}
exit;
}
Or, as in our case, more folklorically:
if(is_method("CANCEL")) {
if(!t_relay_cancel()) {
# Corresponding INVITE transaction found, but error
# occurred.
sl_send_reply("500", "Internal Server Error");
exit;
}
# Corresponding INVITE transaction for CANCEL was not
# found.
exit;
}
In both cases, the corresponding INVITE transaction must exist.
Unfortunately, there's no good alternative. According to RFC 3261
Section 16.11 ("Stateless Proxy"):
Stateless proxies MUST NOT perform special processing for
CANCEL requests. They are processed by the above rules
as any other requests.
So, in other words, route_logic(CANCEL) == route_logic(initial INVITE).
Sometimes, this is possible - with considerable config logic labour -
but other times the path taken by the CANCEL is not so deterministic, as
for example with round-robin load balancing, random distribution,
complex LCR, etc. One is basically left in these situations with the
choice of implementing one's own Call-ID/branch => destination
persistent state database of some kind, which is, to put it mildly,
complicated and undesirable.
Now, if the INVITE transaction receives a final negative reply, this
will get back to the calling UAC, and it will process it correctly.
However, some calls get answered with 2xx. Many UACs will behave
reasonably in this situation: when they don't receive a 200 OK for their
CANCELs but later receive an answer, they will go ahead and send the
end-to-end ACK, then BYE the call. However, they cannot be reliably
counted upon to do this. Some simply get drop the INVITE transaction
after their CANCEL has gone unreplied for a short time, regardless of
whether they receive a final negative reply for it.
Is there a better way? Perhaps a feature can be devised by which
Kamailio keeps some kind of lightweight and restart-persistent map to
which to send the CANCELs? Or perhaps TM is due for a feature that
allows the shm transaction table to be dumped to disk and persisted
across restarts?
Comments welcome. Also, if I'm missing something, please let me know!
-- Alex
[1] https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg#L466
--
Alex Balashov | Principal | Evariste Systems LLC
1447 Peachtree Street NE, Suite 700
Atlanta, GA 30309
United States
Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
Hi,
Is there any way to remove Via and Record-Route headers from requests sent
to an endpoint and update the contact header, but have Kamailio statefully
remember where the replies need to route?
I imagine this would involve mangling the packets slightly to behave
similar to a B2BUA.
My motivations, in order of priority -
1) Reduce UDP packet size to avoid MTU limitations
2) Improve interoperability, don't expect end points to be able to properly
parse / process many via / record-route headers
3) Hide topology.
If someone could point me in the right direction in terms of configuration
or modules, that would be great.
Thanks
I want to get started with Kamailio. So far I've understood that I
really need to grok SIP before tackling Kamailio so I'm reading the book
"SIP demystified" as the starting point of my Kamailio journey. After
that I will read RFC 3261. After that I think it's time to read
something that will give me good understanding of how to actually
implement applications with Kamailio. Searching Amazon for Kamailio
returns "Building Telephony Systems with OpenSER" as the results that
seems to be most specific to Kamailio. This book is from 2008. Is it
still relevant or is it better to go with the online docs?
regards, Oivvio
I have a problem when using t_suspend() and t_continue().
Let's say I would like to have a 5 sec delay before relaying an INVITE.
For example the following code:
* route[MYROUTE] {*
* t_newtran();*
* if (is_method("INVITE")) {*
* t_reply("100", "Trying");*
* t_reply("180", "In
Queue");*
* $sht(a=>$ci::t_index) =
$T(id_index);*
* $sht(a=>$ci::t_label) =
$T(id_label);*
* $sht(a=>$ci::t_suspended)
= 1;*
* xlog("L_WARN","SUSPENDING
t_index = $sht(a=>$ci::t_index) and t_label = $sht(a=>$ci::t_label)");*
* t_suspend();*
* sleep(5);*
* if (t_is_canceled()) drop;*
* $sht(a=>$ci::t_suspended)
= 0;*
*
t_continue("$avp(t_index)","$avp(t_label)","1");*
* }*
* route(RELAY);*
* exit;*
* }*
* route[1] {*
* xlog("L_WARN","After transaction
continue\n");*
* route(RELAY);*
* exit;*
* }*
When using this code, I get the following error:
Mar 9 16:49:32 mysip /usr/local/sbin/kamailio[5260]: WARNING: <script>:
After transaction continue
Mar 9 16:49:32 mysip /usr/local/sbin/kamailio[5260]: ERROR: <core>
[resolve.c:1693]: sip_hostport2su(): could not resolve hostname: "mysip"
Mar 9 16:49:32 mysip /usr/local/sbin/kamailio[5260]: ERROR: tm [ut.h:319]:
uri2dst2(): failed to resolve "mysip"
Mar 9 16:49:32 mysip /usr/local/sbin/kamailio[5260]: ERROR: tm
[t_fwd.c:1711]: t_forward_nonack(): ERROR: t_forward_nonack: failure to add
branches
Mar 9 16:49:32 mysip /usr/local/sbin/kamailio[5260]: ERROR: sl
[sl_funcs.c:363]: sl_reply_error(): ERROR: sl_reply_error used:
Unresolvable destination (478/SL)
Mar 9 16:49:32 mysip /usr/local/sbin/kamailio[5260]: BUG: tm
[t_lookup.c:1481]: t_unref(): tm: t_unref: REQ_ERR DELAYED should have been
caught much earlier for 0x7fd4e727a468: 27 (hex 1b)
If I try to t_continue() without any route:
t_continue("$avp(t_index)","$avp(t_label)","");
The call is working great and the following error pops up:
Mar 9 17:10:36 mysip /usr/local/sbin/kamailio[5830]: ERROR: tmx
[tmx_mod.c:635]: w_t_continue(): empty action lists in route block []
Am I doing something wrong?
My other question is regarding CANCEL.
Let's assume I suspended the INVITE and in these 5 sec I received CANCEL
for it.
Is there a short and elegant way to remove the transaction from suspension?
For now I do:
* if (is_method("CANCEL")) {*
* if (t_check_trans()) {*
*
if($sht(a=>$ci::t_suspended) == 1) {*
*
t_continue("$sht(a=>$ci::t_index)","$sht(a=>$ci::t_label)","");*
*
xlog("L_WARN","After transaction continue\n");*
* }*
* route(RELAY);*
* }*
* exit;*
* }*
Thanks,
Uri
Hi all,
I work on Kazoo system.
I have NAT problem when configure Freeswitch and Kamailio.
As the old network diagram:
<https://lh3.googleusercontent.com/-dVJit4UPAL8/VuI4z1LBdKI/AAAAAAAABDo/zSG0…>
I configure dispatcher to FS 1,2 with IP private and map IP public <-> IP
private for each server via Router.
This work fine.
Then now, I want to improve FS performance so that I set up new FS with IP
public:
<https://lh3.googleusercontent.com/-YZl8d3HBo8E/VuI7ChgTGzI/AAAAAAAABD0/AQQW…>
I configure dispatcher FS3 with IP public, connection between FS3 &
ecallmgr via public IP is Okay but have problem with NAT:
*When Kamailio foward SIP INVITE message to FS3 then FS3 response 200 OK
message but it send to Ip private of Kamailio not IP public.*
As Kamailio I have already configure advertise IP public:
local.cfg
listen=UDP_SIP advertise 125.212.212.40:5060
listen=TCP_SIP advertise 125.212.212.40:5060
View console log on Freeswitch, I see the ecallmgr response to FS3:
1. bridge({outbound_redirect_fatal="false",call_timeout=20,
originate_timeout=20,local_var_clobber="true"}[ecallmgr_Authorizing-ID=
"71310939684a2c8acc4e0e6dff1be6c2",ecallmgr_Owner-ID=
"188cd101dcea060d080261b328fdf1ca",ecallmgr_Account-ID=
"3f221d1ce6959ec04acd372923e253b9",sdp_secure_savp_only="false",
sip_invite_domain="hahai1412.anttel-pro.ab-kz-02.antbuddy.com",
presence_id="sharklasers(a)hahai1412.anttel-pro.ab-kz-02.antbuddy.com
<https://happy.antbuddy.com/sharklasers@hahai1412.anttel-pro.ab-kz-02.antbud…>
",sip_h_X-KAZOO-AOR=sip:sharklasers@hahai1412.anttel-pro.ab-kz-
02.antbuddy.com,absolute_codec_string="^^:PCMU:VP8",leg_timeout="20",
effective_callee_id_number="sharklasers",effective_callee_id_name=
"sharklasers ",origination_callee_id_number="sharklasers",
origination_callee_id_name="sharklasers ",ecallmgr_Realm="
hahai1412.anttel-pro.ab-kz-02.antbuddy.com",ecallmgr_Username=
"sharklasers"]sofia/sipinterface_1/sharklasers@113.161.89.159:5914
<https://happy.antbuddy.com/sharklasers@113.161.89.159:5914>;transport=ws
;*fs_path=sip:10.127.15.36:5060*;lr;received="sip:113.161.89.159:5914
;transport=ws")
I research fs_path parameter:
https://wiki.freeswitch.org/wiki/Sofia-SIP#Specifying_SIP_Proxy_With_fs_path
I guess this is broken It should be Public IP:
*fs_path=sip:125.212.212.40:5060*. But I don't know how I can change this
parameter !
Anybody faced that problem ? Any solution ?
Regards,
Hai Bui
--
Hai Bui
VoIP engineer, Cvoice team, HTK-HCM Office
Mobile: +84-165-618-9876
Hello
I have been running kamailio on local network including rtpengine and
freeswitch.
Now i am configuring kamailio with my public IP(trying with stock kamailio
configuration to get started)
#define WITH_NAT
listen=udp:192.168.3.32:5060
listen=tcp:192.168.3.32:5060
advertised_address= "122.xx.xx.xx"
advertised_port="5060"
and also using rtpengine module at udp:192.168.3.32:22222
now the problems i am facing are
1.> UA can't register with UDP transport(not even recieving any packets at
server ,testing with IMSdroid).
2.>TCP is registering the user, but users can't make calls .
i've also noticed this error in /var/log/syslog when tcp ca't make calls
ERROR: <core> [tcp_main.c:4250]: tcpconn_main_timeout(): connect
100.68.181.111:50842 failed (timeout)
please help me out
Hi folk!
I am trying to implement srv_query usage in my script (server is based on
Kamailio+Asterisk).
The task: when outgoing REGISTER comes from Asterisk (outgoing trunk to
operator), and R-URI consists domain name, need to store all ip-addresses of
remote side (for following use)
Currently, this works using dns_query, and storing in htable structure with
remote IPs.
But if remote side use SRV, I do not have all IPs
Trying to use srv_query function from ipops, I am stuck with following:
- srv_query(srvcname, pvid)
to get srvcname - for example, "_sip._tcp.example.com",
I need to provide, NAPTR record lookup (that is according to RFC3263, and
Kamailio does this in core, while request processing)
but I see no way how to make NAPTR lookup from script (not involving non
Kamailio tools)
Looking in mail list archive, found nothing that could help. What I am
missing, is there an easy solution, how to cope with my case?
Would appreciate any suggestion or idea.
Cheers!
--
View this message in context: http://sip-router.1086192.n5.nabble.com/srv-query-question-tp146546.html
Sent from the Users mailing list archive at Nabble.com.
Hello everyone,I have Kamailio server which runs at 192.168.2.170 address and have PostgreSQL server which runs at 192.168.2.174.So I tried to arrange Kamailio for working with PostgreSQL but I think I give something miss. I couldnt handle it.Do you have any tutorial for this? Or can you tell me how can I exactly do this?Regards.