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.
--
--Mojtaba Esfandiari.S