Hello,
the issue is triggered by the fact that the JSON document has $xyz
tokens (e.g., $oid), which match the kamailio variables format, and the
jansson_get() tries to replace them, but no such variable is exported by
kamailio, throwing an error.
Try to replace $ with $$ inside the $var(data), something like:
$var(m) = "$";
$var(r) = "$$";
$var(newdata) = $(var(data){s.replace,$var(m),$var(r)});
Let us know if works, if now, we have to look at the code of jansson
module and see how it evaluates its parameters for functions.
Cheers,
Daniel
On 08.01.18 08:33, Mojtaba wrote:
Hello,
I used ndbmongo module in kamailio,
I used mongodb_find command to get some data from mongo, like this:
if(mongodb_find("sermongo", "Asterisk", "user", "{
\"number\" :
\"$fU\" }", "res")) {
xlog("L_INFO", "Data from mongodb is \"
$mongodb(res=>value) \" \n");
$var(data) = $mongodb(res=>value);
}
The result in syslog is like this:
Jan 8 07:23:36 ubuntu14 /usr/local/sbin/kamailio[12127]: {1 2 INVITE
MDRlMjRlNGVjZGY1Y2JkYjA5OGM2ZTg1ZTFjZTk0Nzg.} INFO: <script>: user
Data from mongodb is " { "_id" : { "$oid" :
"5916def36803fa48468b456b"
}, "user_type" : "SIP", "context" :
"main_routing", "deny" :
"0.0.0.0/0.0.0.0", "call_record" : "no",
"dtmfmode" : "rfc2833",
"canreinvite" : "no", "directmedia" : "no",
"host" : "dynamic", "type"
: "friend", "nat" : "force_rport,comedia", "port"
: "5060", "qualify"
: "yes", "callgroup" : "1", "pickupgroup" :
"1", "permit" :
"0.0.0.0/0.0.0.0", "callcounter" : "yes",
"faxdetect" : "no",
"call_limit" : "", "name" : "1000",
"number" : "1000", "cid_number" :
"1000", "secret" : "123123", "date" : {
"$date" : 1494671091612 },
"more_options" : "" } "
Now i need to get just some keys like "context" from json and save
them in PV, i used jansson2.10 for doing this job, like this:
jansson_get("user.context", $var(jdata), "$var(context)");
but i have this error in syslog:
Jan 8 07:23:36 ubuntu14 /usr/local/sbin/kamailio[12127]: {1 2 INVITE
MDRlMjRlNGVjZGY1Y2JkYjA5OGM2ZTg1ZTFjZTk0Nzg.} ERROR: <core>
[core/pvapi.c:903]: pv_parse_spec2(): error searching pvar "oid"
Jan 8 07:23:36 ubuntu14 /usr/local/sbin/kamailio[12127]: {1 2 INVITE
MDRlMjRlNGVjZGY1Y2JkYjA5OGM2ZTg1ZTFjZTk0Nzg.} ERROR: <core>
[core/pvapi.c:1107]: pv_parse_spec2(): wrong char [d/100] in [$oid] at
[3 (0)]
Jan 8 07:23:36 ubuntu14 /usr/local/sbin/kamailio[12127]: {1 2 INVITE
MDRlMjRlNGVjZGY1Y2JkYjA5OGM2ZTg1ZTFjZTk0Nzg.} ERROR: <core>
[core/sr_module.c:1268]: fix_param(): bad PVE format: "{ "_id" : {
"$oid" : "5916def36803fa48468b456b" }, "user_type" :
"SIP", "context"
: "main_routing", "deny" : "0.0.0.0/0.0.0.0",
"call_record" : "no",
"dtmfmode" : "rfc2833", "canreinvite" : "no",
"directmedia" : "no",
"host" : "dynamic", "type" : "friend",
"nat" : "force_rport,comedia",
"port" : "5060", "qualify" : "yes",
"callgroup" : "1", "pickupgroup" :
"1", "permit" : "0.0.0.0/0.0.0.0", "callcounter"
: "yes", "faxdetect"
: "no", "call_limit" : "", "name" :
"1000", "number" : "1000",
"cid_number" : "1000", "secret" : "123123",
"date" : { "$date" :
1494671091612 }, "more_options" : "" }"
Jan 8 07:23:36 ubuntu14 /usr/local/sbin/kamailio[12127]: {1 2 INVITE
MDRlMjRlNGVjZGY1Y2JkYjA5OGM2ZTg1ZTFjZTk0Nzg.} ERROR: <core>
[core/mod_fix.c:564]: fixup_spve_null(): Cannot convert function
parameter 1 to spve
Jan 8 07:23:36 ubuntu14 /usr/local/sbin/kamailio[12127]: {1 2 INVITE
MDRlMjRlNGVjZGY1Y2JkYjA5OGM2ZTg1ZTFjZTk0Nzg.} ERROR: <core>
[core/action.c:1139]: do_action(): runtime fixup failed for
jansson_get param 2
Jan 8 07:23:36 ubuntu14 /usr/local/sbin/kamailio[12127]: {1 2 INVITE
MDRlMjRlNGVjZGY1Y2JkYjA5OGM2ZTg1ZTFjZTk0Nzg.} ERROR: <core>
[core/action.c:1518]: do_action(): run action error at:
/usr/local/etc/kamailio/kamailio.cfg:990
Jan 8 07:23:36 ubuntu14 /usr/local/sbin/kamailio[12127]: {1 2 INVITE
MDRlMjRlNGVjZGY1Y2JkYjA5OGM2ZTg1ZTFjZTk0Nzg.} ERROR: <script>: Send
SIP message to Simotel <192.168.122.1:36854>
Let me know how i could fixed this Error in regard of [$oid]?
Thanks with regards.
--
Daniel-Constantin Mierla
www.twitter.com/miconda --
www.linkedin.com/in/miconda
Kamailio Advanced Training - March 5-7, 2018, Berlin -
www.asipto.com
Kamailio World Conference - May 14-16, 2018 -
www.kamailioworld.com