It seems I'm missing something when checking the structure. I've multiple entries in the database now that seem to have exactly the same types, but the config works for one, and gives an error on the other one:
{ "_id" : ObjectId("597b5698e498421a40458dc3"), "uuid" : "", "attribute" : "email", "value" : "sip:555@bla.bla", "type" : 0, "username" : "555", "domain" : null } { "_id" : ObjectId("597b5d9a61d1521f067391ae"), "uuid" : "", "attribute" : "email", "value" : "sip:123@bla.bla", "type" : 0, "username" : "666", "domain" : null }
I compared all the types, and they're the same, using statements like:
typeof db.usr_preferences.findOne({"username":"666"})._id
The first entry has been made by using: avp_db_delete("$to/username","$avp(s:email)"); avp_printf("$avp(s:email)","$ruri"); avp_db_store("$to/username","$avp(s:email)"); So, using kamailio. The second version has been created by me manually in the database (which is what I'll do for the real entries).
The first entry now works fine, but the second one gives the following error: ERROR: <core> [usr_avp.c:424]: search_avp(): 0 ID or NULL NAME AVP! when using the initial code again:
if (avp_db_load("$to/username", "$avp(s:email)")) { xlog("bla02"); }
Where does the second entry differ?
Sent: Wednesday, July 26, 2017 at 6:58 PM From: "Sebastian Damm" damm@sipgate.de To: "Kamailio (SER) - Users Mailing List" sr-users@lists.kamailio.org Subject: Re: [SR-Users] error using avp_db_load with mongodb
Hi,
I've seen this before, but with MySQL. Kamailio is pretty strict with data types of database fields. IIRC I tried to use it with a view and the view returned a string value where Kamailio expected an integer and threw the same error. So maybe you might want to check the reference structure of the usr_preferences table under https://github.com/kamailio/kamailio/blob/master/utils/kamctl/mongodb/kamail... with your local structure.
HTH Sebastian
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users