I'm trying to setup the kamailio dialplan module with mongodb as a backend. The configuration worked with mysql as a backend, and the other modules I use (subscriber, location) work fine with mongodb now.
The relevant config in kamailio.cfg:
#!define DBURL "mongodb://localhost/kamailio"
loadmodule "dialplan.so"
modparam("dialplan", "db_url", DBURL)
And in the main route I use:
if (dp_translate("100")) {
xlog("dialplan: translation succeeded\n");
}
else {
xlog("dialplan: translation failed\n");
}
In mongodb, I got:
> db.getCollection("version").find({"table_name":"dialplan"})
{ "_id" : ObjectId("589de6af3d305445959b19d9"), "table_name" : "dialplan", "table_version" : 2 }
> db.dialplan.find()
{ "_id" : ObjectId("589dec2f3d305445959b19db"), "dpid" : 100, "pr" : 50, "match_op" : 1, "match_exp" : "^003$", "match_len" : 0, "subst_exp" : "^003$", "repl_exp" : "11111", "attrs" : "abc" }
But the module fails to apply this. For example:
$kamcmd dialplan.dump 100
error: 500 - Dialplan ID not matched
What am I doing wrong?
The problem was that some of the values should be ints (as specified in dialplan.json), which I didn't specify on insert. When I do:
db.dialplan.insert( { "dpid" : NumberInt(100), "pr": NumberInt(1), "match_op" : NumberInt(1), "match_exp" : "^003$", "match_len" : NumberInt(0), "subst_exp" : "^003$", "repl_exp" : "11111", "attrs" : "abc" } )
Everything works fine:
$kamcmd dialplan.translate 100 s:003
{
Output: 11111
Attributes: abc
}