Hi MS/Daniel
Need your help for one issue which I am facing on kamailio. I am unable to
cancel call on 180 or 183 ringing. Could you help me please for that. Below is
the my complete code for your referance.
#!KAMAILIO
####### Global Parameters #########
debug=3
log_stderror=no
children=4
tcp_accept_no_cl=yes
listen=udp:172.26.2.185:5060
listen=tcp:0.0.0.0:8080
alias=172.26.2.185
####### Modules Section ########
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "xlog.so"
loadmodule "textops.so"
loadmodule "maxfwd.so"
loadmodule "sanity.so"
loadmodule "siputils.so"
loadmodule "xhttp.so"
loadmodule "uac.so"
loadmodule "htable.so"
loadmodule "http_async_client.so"
#loadmodule "dialog.so" # Required for provisional replies catch
loadmodule "ims_dialog.so"
####### Module-specific Parameters ########
modparam("tm", "fr_timer", 30000)
modparam("tm", "fr_inv_timer", 120000)
modparam("tm", "restart_fr_on_each_reply", 0)
modparam("tm", "enable_uac_fr", 1)
modparam("rr", "enable_full_lr", 1)
modparam("htable", "htable", "obdmap=>size=10;autoexpire=300;")
modparam("ims_dialog", "dlg_flag", 4)
####### Routing Logic ########
request_route {
if (!sanity_check("1511", "7")) exit;
if (!mf_process_maxfwd_header("10")) exit;
xlog("L_INFO", "-> $rm $ru from $si:$sp Call-ID: $ci\n");
if (is_method("CANCEL|ACK|BYE")) {
if (t_check_trans()) {
t_relay();
}
exit;
}
if (!is_method("INVITE|OPTIONS")) {
sl_send_reply("405", "Method Not Allowed");
exit;
}
if ($rm == "OPTIONS") {
sl_send_reply("200", "OK");
exit;
}
if (is_method("INVITE")) {
record_route();
setflag(4);
# dlg_manage(); # ?? THIS IS THE MISSING LINE
t_relay();
if (!t_relay()) {
sl_reply_error();
}
exit;
}
}
####### HTTP Trigger - Outbound Call (OBD) ########
event_route[xhttp:request] {
if ($hu =~ "^/v1/obd-notifications/") {
$var(msisdn) = $(hu{s.select,3,/});
# Temporary hardcoded request_id - for testing
$var(request_id) = $(hu{s.select,4,/});
# When ready, uncomment this line and comment out the hardcoded one
# $var(request_id) = $param(request_id);
xlog("L_INFO", "HTTP OBD request - msisdn=[$var(msisdn)]
request_id=[$var(request_id)]\n");
if (!$var(msisdn) || !$var(request_id)) {
xlog("L_ERR", "Missing or empty params - msisdn or request_id\n");
xhttp_reply("400", "Bad Request", "text/plain", "Missing msisdn or
request_id\n");
exit;
}
$var(callid) = $(mb{s.md5});
# Save correlation
$sht(obdmap=>$var(callid)) = $var(request_id);
xlog("L_INFO", "OBD triggered -> msisdn=$var(msisdn)
rid=$var(request_id) callid=$var(callid)\n");
setflag(4);
# Prepare outbound INVITE
$uac_req(method) = "INVITE";
$uac_req(ruri) = "sip:" + $var(msisdn) + "@SIP_TRUNK_IP";
$uac_req(furi) = "sip:[email protected]";
$uac_req(turi) = $uac_req(ruri);
$uac_req(callid) = $var(callid);
$uac_req(hdrs) = "X-Request-ID: $var(request_id)\r\n" +
"Supported: 100rel\r\n" +
"Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, PRACK,
INFO, UPDATE\r\n";
uac_req_send();
# Start dialog tracking
# Set reply route for 180/183
t_on_reply("RINGING_CANCEL");
xhttp_reply("202", "Accepted", "text/plain", "Call attempt started\n");
exit;
}
xhttp_reply("404", "Not Found", "text/plain", "Invalid endpoint\n");
}
####### Exact 180/183 ? Cancel + Callback (No Timer) ########
onreply_route[RINGING_CANCEL] {
if ($rs =~ "^18[03]$") { # 180 or 183
$var(rid) = $sht(obdmap=>$ci);
if ($var(rid)) {
xlog("L_WARN", "$rs DETECTED ? PRACK/CANCEL CHECK |
rid=$var(rid)\n");
setflag(4);
# If 183 and PRACK required ? send PRACK
if ($rs == "183" && ($hdr(Require) =~ "100rel" ||
pv_isset("$hdr(RSeq)"))) {
xlog("L_INFO", "183 requires PRACK ? sending PRACK\n");
dlg_terminate("all", "Reason: OBD Ring Cancel\r\n");
$uac_req(method) = "PRACK";
$uac_req(ruri) = $ru;
$uac_req(furi) = $fu;
$uac_req(turi) = $tu;
$uac_req(hdrs) = "RAck: 10 $hdr(RSeq) INVITE\r\n" +
"Supported: 100rel\r\n";
uac_req_send();
}
$sht(obdmap=>$ci) = $null;
}
}
}
event_route[uac:reply] {
xlog("L_INFO", "uac:reply ? code=$uac_req(evcode)
callid=$uac_req(callid)\n");
$var(rid) = $sht(obdmap=>$uac_req(callid));
if ($var(rid)) {
$sht(obdmap=>$uac_req(callid)) = $null;
}
}
________________________________
From: Sarju Garg <[email protected]>
Sent: Wednesday, January 28, 2026 2:41 PM
To: M S <[email protected]>
Cc: Chandra Bhan <[email protected]>; Kamailio (SER) - Development
Mailing List <[email protected]>; Daniel-Constantin Mierla
<[email protected]>
Subject: Re: [sr-dev] OBD Based Missed Call issue
Hi,
I have one more question.
We read there are multiple methods for scripting and found (again chatgpt) that
python is the best one. Is it so for our kind of application.?
Also, is there any good book on kamalio architecture and building application?
Regards
Sarju
From: Sarju Garg <[email protected]>
Date: Wednesday, 28 January 2026 at 10:11 AM
To: M S <[email protected]>
Cc: Chandra Bhan <[email protected]>, "Kamailio (SER) - Development
Mailing List" <[email protected]>, Daniel-Constantin Mierla
<[email protected]>
Subject: Re: [sr-dev] OBD Based Missed Call issue
Hi,
Thanks for explaining in detail.
Our service logic is simple and I believe that Kamalio itself can deliver
results. Again, this is my limited knowledge.
We will try reading this but we made one but getting some error.
My team mate Chandra, share one code last time which you mentioned it has some
problem. Can you help with that.
Do we have some sample code for telecom grade VAS application like MCA etc.
Regards
Sarju
From: M S <[email protected]>
Date: Wednesday, 28 January 2026 at 9:40 AM
To: Sarju Garg <[email protected]>
Cc: Chandra Bhan <[email protected]>, "Kamailio (SER) - Development
Mailing List" <[email protected]>, Daniel-Constantin Mierla
<[email protected]>
Subject: Re: [sr-dev] OBD Based Missed Call issue
Thank you for explaining your project, it make much more sense now.
The UAC module is typically used to send SIP ping (SIP OPTIONS requests) to
remote gateways to check their availability, as well as to do cascade SIP
registration etc.
Theoretically, you can use it to send SIP INVITE but it would likely create
more problems then solutions, just like theoretically you can drive a car over
a railway track but it would be hell of a bumpy ride.
Nevertheless, take a look at uac_send documentation which explains its usage
with example, just copy/paste the example and adopt it for your needs e.g.
change SIP method to INVITE, set correct TO, FROM, CONTACT and VIA headers etc.
so the destination can receive your request and you can receive its responses
etc. This will only work if destination does not do authentication and
authorization, otherwise you have to track destination responses and do
authentication as well using same uac_send method.
To send SIP request to remote gateway,
https://kamailio.org/docs/modules/devel/modules/uac.html#uac.f.uac_req_send
To receive responses from remote gateway and process them (e.g. for
authentication),
https://kamailio.org/docs/modules/devel/modules/uac.html#uac.ert.uac_reply
Regards.
On Wed, 28 Jan 2026, 02:36 Sarju Garg,
<[email protected]<mailto:[email protected]>> wrote:
Hi,
Sorry for bothering you again.
We did read your mail and then also read a lot on ChatGPT and got big time
CONFUSED.
Just to clarify, we are building a missed OBD/IBD platform with zero media
involvement and only SIP signalling. We are only planning to do missed OBD
where we dial the number and disconnect as soon as call rings. There is no
media involved in the call. Also, we would like to build a missed call service
where a party call us, and we send 480 busy here. Here too, no media is
involved.
The link below have reference to UAC module. If kamalio is only a router, why
UAC functionality is required.
I agree with you that if need media functionalty then rtp_engine and external
node is required.
Please bear with us to write you back but we have build a highly scalable call
transaction per system and looking forward to do it only with Kamalio and no
asterisk etc.
Regards
Sarju
From: M S <[email protected]<mailto:[email protected]>>
Date: Tuesday, 27 January 2026 at 11:09 PM
To: Chandra Bhan <[email protected]<mailto:[email protected]>>
Cc: "Kamailio (SER) - Development Mailing List"
<[email protected]<mailto:[email protected]>>,
Daniel-Constantin Mierla <[email protected]<mailto:[email protected]>>, Sarju
Garg <[email protected]<mailto:[email protected]>>
Subject: Re: [sr-dev] OBD Based Missed Call issue
Please read my last email again. Kamailio is NOT an outbound dialer. Trying to
originate an outbound call from it is NOT possible. Whoever told you otherwise
is wrong and has misguided you.
Also, the example code that you mentioned is incorrect as well. Please check
kamailio documentation of relevant modules at,
https://kamailio.org/docs/modules/devel/
Regards.
On Tue, 27 Jan 2026, 10:09 Chandra Bhan,
<[email protected]<mailto:[email protected]>> wrote:
Hi
Response is awaited
Thanks & Regards
Chandra Bhan Singh
Mobile No:- 09999909109
On Mon, 26 Jan, 2026, 19:53 Chandra Bhan,
<[email protected]<mailto:[email protected]>> wrote:
Hi M S,
Thank you so much for your quick response.
I should mention that I don’t have deep expertise in Kamailio. I’ve been doing
a lot of browsing and research (including ChatGPT), and based on that I found a
few possible approaches to make outbound calls directly from Kamailio using a
SIP trunk.
Some of the methods I came across are:
* uac_send_request
* app_lua
* jsonrpc_exec
My goal is to originate outbound calls directly from Kamailio (without
Asterisk) toward a GSM/SIP gateway. I’m not fully sure which approach is the
most appropriate or recommended in a production setup.
I would really appreciate your guidance on the correct and supported way to
achieve this.
Thanks again for your time and support.
For your reference I am sharing some sample code of two method
1st method
event_route[xhttp:request] {
if ($hu =~ "^/obd") {
$avp(msisdn) = $(hu{param.value,msisdn});
if ($avp(msisdn) == $null) {
xhttp_reply("400", "Bad Request", "text/plain",
"Missing msisdn\n");
exit;
}
# Destination URI for the call
$var(dst_uri) = "sip:" + $avp(msisdn) +
"@182.77.59.145:5060<http://182.77.59.145:5060>";
# From URI (mandatory)
$var(from_uri) =
"sip:[email protected]<mailto:sip%[email protected]>";
xlog("L_INFO", "Calling GSM number: $var(dst_uri)\n");
# Send INVITE using UAC
uac_req_send(
"INVITE",
$var(dst_uri),
$var(from_uri),
"",
""
);
xhttp_reply("200", "OK", "text/plain",
"Call initiated\n");
exit;
}
xhttp_reply("404", "Not Found", "text/plain", "Not Found\n");
exit;
}
2nd method .
event_route[xhttp:request] {
if ($hu !~ "^/obd/") {
xhttp_reply("404", "Not Found", "", "");
exit;
}
$var(uri) = $hu;
$var(callee) = $(var(uri){s.select,3,/});
if ($var(callee) == "") {
xhttp_reply("400", "Missing MSISDN", "", "");
exit;
}
xlog("L_INFO", "OBD HTTP caller=9999909109 callee=$var(callee)\n");
$var(json) = "{\"jsonrpc\":\"2.0\",\"method\":\"dialog.bridge_dlg\","
"\"params\":[\"sip:[email protected]<mailto:sip%[email protected]>\","
"\"sip:$var(callee)@182.77.59.145<http://182.77.59.145>\"],\"id\":1}";
jsonrpc_exec($var(json));
xhttp_reply("200", "OK", "", "OBD triggered\n");
exit;
}
Regards
Chandra Bhan Kumar
________________________________
From: M S <[email protected]<mailto:[email protected]>>
Sent: Monday, January 26, 2026 7:30 PM
To: Kamailio (SER) - Development Mailing List
<[email protected]<mailto:[email protected]>>
Cc: Daniel-Constantin Mierla <[email protected]<mailto:[email protected]>>;
Chandra Bhan <[email protected]<mailto:[email protected]>>
Subject: Re: [sr-dev] OBD Based Missed Call issue
Kamailio is NOT a media endpoint nor a media gateway. It is a SIP proxy that
routes call between two endpoints, gateways or proxies. What you seems to do is
trying to originate a call from Kamailio to some provider, which will simply
not work.
For Outbound Dialer service you need to setup some media gateway like Asterisk,
Freeswitch or CUCM (Cisco Unified Media Gateway) etc.
Regards.
--
Muhammad Shahzad Shafi.
Tel: +49 176 99 83 10 85
On Mon, 26 Jan 2026, 13:45 Chandra Bhan via sr-dev,
<[email protected]<mailto:[email protected]>> wrote:
Hi Daniel
I hope you are doing well. Looking for your support on kamailio.
I am a new for kamailio. I want to build setup OBD Based Missed Call Solution
1. I able to send http request on kamailio but call not getting dial due to
some reason
Here is my code. Could you help me to resolve the issue.
#!KAMAILIO
####### Global Parameters #########
debug=3
log_stderror=yes
memdbg=5
memlog=5
children=8
tcp_accept_no_cl=yes
auto_aliases=no
listen=udp:172.26.12.138:5060<http://172.26.12.138:5060>
listen=tcp:0.0.0.0:8080<http://0.0.0.0:8080>
alias=your.public.ip # optional
####### Modules Section ########
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "xlog.so"
loadmodule "textops.so"
loadmodule "maxfwd.so"
loadmodule "sanity.so"
loadmodule "siputils.so"
loadmodule "xhttp.so"
loadmodule "uac.so"
####### Module Parameters ########
# --- TM
modparam("tm", "fr_timer", 5000)
modparam("tm", "fr_inv_timer", 30000)
# --- RR
modparam("rr", "enable_double_rr", 1)
modparam("rr", "append_fromtag", 1)
# --- UAC (authentication profile)
# format:
# name => sip:proxy, username, password
modparam("uac", "uac_reg",
"obd => sip:GSM-Gateway-IP:5060,2555,123456"
)
####### Routing Logic ########
request_route {
# Sanity checks
if (!sanity_check("1511", "7")) {
xlog("L_ERR", "Sanity failed\n");
drop;
}
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483", "Too Many Hops");
exit;
}
# Handle HTTP requests
if ($Rp == 8080 && $rm == "GET") {
route(HTTP);
exit;
}
# SIP requests (only outbound calls expected)
if (is_method("INVITE")) {
record_route();
t_relay();
exit;
}
if (is_method("ACK|BYE|CANCEL")) {
t_relay();
exit;
}
sl_send_reply("404", "Not Here");
exit;
}
####### HTTP ROUTE ########
route[HTTP] {
if ($hu =~ "^/call") {
# Example:
# http://IP:8080/call?msisdn=9999909109
$var(msisdn) = $param(msisdn);
if ($var(msisdn) == "") {
xhttp_reply("400", "text/plain", "Missing msisdn\n");
exit;
}
xlog("L_INFO", "HTTP Call request for $var(msisdn)\n");
route(OBD_CALL);
xhttp_reply("200", "text/plain", "Call initiated\n");
exit;
}
xhttp_reply("404", "text/plain", "Invalid URL\n");
exit;
}
####### OUTBOUND CALL ROUTE ########
route[OBD_CALL] {
$var(dst_uri) = "sip:" + $var(msisdn) + "@GSM-Gateway-IP:5060";
xlog("L_INFO", "Calling $var(dst_uri)\n");
uac_req_send(
"INVITE",
$var(dst_uri),
"sip:[email protected]",
"sip:" + $var(msisdn) + "@your.domain",
"",
"obd"
);
exit;
}
_______________________________________________
Kamailio - Development Mailing List --
[email protected]<mailto:[email protected]>
To unsubscribe send an email to
[email protected]<mailto:[email protected]>
Important: keep the mailing list in the recipients, do not reply only to the
sender!
_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the
sender!