Hi Volker
your comments were helpful, now I am 1 step further
and reached the
next challenge:
https://lists.kamailio.org/mailman3/hyperkitty/list/sr-users@lists.kamailio…
Did you enable one of the DB modes?
/* enable DB persistency for location entries */
modparam("usrloc", "db_url", DBLOCAL)
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "use_domain", 0)
RPC functions are restricted in the reply size. I found by try and
error, that this limit is at about 1MB and I found no way to increase that limit.
We therefore took another approach and started building our own API
using the jansson module to directly access the database and only
return the information we are (or our customer service using our
diagnosis service) is interested in.
Here the snippet with might be interesting for you.
event_route[xhttp:request] {
route(DEBUGINIT);
if ($avp(debug) > 0) {
xlog("L_INFO", "$cfg(route): XHTTP Request to URI: $hu Port: $Rp
BODY: $rb\n");
}
if ($Rp != 8080) {
xhttp_reply("403", "Forbidden", "text/html",
"<html><body>Talk SIP to me dude!</body></html>");
exit;
}
if ($hu =~ "^/RPC") {
### KAMAILIO JSONRCP passthrough
jsonrpc_dispatch();
} else if ($hu =~ "^/API") {
### CUSTOM API
$var(json_reply) = "{}";
jansson_get("method","$rb","$var(method)");
jansson_get("id","$rb","$var(id)");
jansson_set("string","jsonrpc","2.0","$var(json_reply)");
jansson_set("string","id","$var(id)","$var(json_reply)");
jansson_set("obj","result","{}","$var(json_reply)");
[...]
} else if ($var(method) == "location.lookup.by_aor") {
# Registration Lookup by AoR
jansson_get("params[0]","$rb","$var(aor)");
$var(query) = "SELECT
username,contact,last_modified,expires,callid,user_agent from location"
" where username = '" + $var(aor) +
"'";
$var(query_result) = sql_query("localacc",
"$var(query)","sql_res");
if($dbr(sql_res=>rows)>0) {
$var(i)=0;
$var(aor_a) = '[]';
while($var(i)<$dbr(sql_res=>rows)) {
$var(aor_o) = '{}';
jansson_set("string","username",
"$dbr(sql_res=>[$var(i),0])","$var(aor_o)");
jansson_set("string","contact",
"$dbr(sql_res=>[$var(i),1])","$var(aor_o)");
jansson_set("string","last_modified","$dbr(sql_res=>[$var(i),2])","$var(aor_o)");
jansson_set("string","expires",
"$dbr(sql_res=>[$var(i),3])","$var(aor_o)");
jansson_set("string","callid",
"$dbr(sql_res=>[$var(i),4])","$var(aor_o)");
jansson_set("string","user_agent",
"$dbr(sql_res=>[$var(i),5])","$var(aor_o)");
jansson_append("obj","","$var(aor_o)","$var(aor_a)");
$var(i) = $var(i) + 1;
}
jansson_set("array","result","$var(aor_a)","$var(json_reply)");
sql_result_free("sql_res");
} else {
jansson_set("string","result.error","No
entries","$var(json_reply)");
sql_result_free("sql_res");
}
} else if ($var(method) == "location.list_all") {
[...]
} else {
jansson_set("string","result.error","Unknown api
call","$var(json_reply)");
}
### SEND REPLY
if ($avp(debug) > 0) {
xlog("L_INFO", "$cfg(route): XHTTP Request to URI: $hu
Method: $var(method) OK\n");
}
xhttp_reply("200", "OK", "application/json",
"$var(json_reply)");
} else {
if ($avp(debug) > 0) {
xlog("L_INFO", "$cfg(route): XHTTP Request to URI: $hu NOT
FOUND\n");
}
xhttp_reply("404", "Not found", "", "");
}
return;
}
--
Mit freundlichen Grüssen
-Benoît Panizzon- @ HomeOffice und normal erreichbar
--
I m p r o W a r e A G - Leiter Commerce Kunden
______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00
CH-4133 Pratteln Fax +41 61 826 93 01
Schweiz Web
http://www.imp.ch
______________________________________________________