2017-02-13 68 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 
}