2017-02-13 63 views
0

我试图将mongodb作为后端安装kamailio dialplan模块。该配置使用mysql作为后端,我使用的其他模块(subscriber,location)现在可以与mongodb一起正常工作。与mongodb一起使用kamailio dialplan模块

在kamailio.cfg相关配置:

#!define DBURL "mongodb://localhost/kamailio" 
loadmodule "dialplan.so" 
modparam("dialplan", "db_url", DBURL) 

,并在主路线我用:

if (dp_translate("100")) { 
     xlog("dialplan: translation succeeded\n"); 
} 
else { 
     xlog("dialplan: translation failed\n"); 
} 

在MongoDB中,我得到了:

> 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" } 

但模块未能应用此。例如:

$kamcmd dialplan.dump 100 
error: 500 - Dialplan ID not matched 

我在做什么错?

回答

0

问题是某些值应该是整数(如dialplan.json中指定的),我没有在插入时指定它。当我这样做:

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" }) 

一切正常:

$kamcmd dialplan.translate 100 s:003 
{ 
    Output: 11111 
    Attributes: abc 
}