Hello!

I want to keep user location in mongodb, but Kamailio does not start well.

Configuration:

loadmodule "usrloc.so"
loadmodule "db_mongodb.so"
modparam("usrloc", "db_insert_null", 1)
modparam("usrloc", "db_url", "mongodb://mongodb.test/kamailio")
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "timer_interval", 30)
modparam("usrloc", "desc_time_order", 1)


Mongodb:

rs0:PRIMARY> use kamailio
switched to db kamailio
rs0:PRIMARY> db.location.find()
{ "_id" : ObjectId("5be024d6b9d8febf4ae19681"), "name" : "location", "version" : 9, "columns" : { "id" : { "type" : "int", "default" : null, "null" : false }, "ruid" : { "type" : "string", "default" : "", "null" : false }, "username" : { "type" : "string", "default" : "", "null" : false }, "domain" : { "type" : "string", "default" : null, "null" : true }, "contact" : { "type" : "string", "default" : "", "null" : false }, "received" : { "type" : "string", "default" : null, "null" : true }, "path" : { "type" : "string", "default" : null, "null" : true }, "expires" : { "type" : "datetime", "default" : "2030-05-28 21:32:15", "null" : false }, "q" : { "type" : "double", "default" : 1, "null" : false }, "callid" : { "type" : "string", "default" : "Default-Call-ID", "null" : false }, "cseq" : { "type" : "int", "default" : 1, "null" : false }, "last_modified" : { "type" : "datetime", "default" : "2000-01-01 00:00:01", "null" : false }, "flags" : { "type" : "int", "default" : 0, "null" : false }, "cflags" : { "type" : "int", "default" : 0, "null" : false }, "user_agent" : { "type" : "string", "default" : "", "null" : false }, "socket" : { "type" : "string", "default" : null, "null" : true }, "methods" : { "type" : "int", "default" : null, "null" : true }, "instance" : { "type" : "string", "default" : null, "null" : true }, "reg_id" : { "type" : "int", "default" : 0, "null" : false }, "server_id" : { "type" : "int", "default" : 0, "null" : false }, "connection_id" : { "type" : "int", "default" : 0, "null" : false }, "keepalive" : { "type" : "int", "default" : 0, "null" : false }, "partition" : { "type" : "int", "default" : 0, "null" : false } } }
{ "_id" : ObjectId("5be02a77175610be86a1a589"), "username" : "dummy_user" }


Syslog:

Nov  5 12:51:01 dev-rtpengine /usr/sbin/kamailio[21543]: ERROR: db_mongodb [mongodb_dbase.c:416]: db_mongodb_get_columns(): field [username] not found in result iterator
Nov  5 12:51:01 dev-rtpengine /usr/sbin/kamailio[21543]: ERROR: db_mongodb [mongodb_dbase.c:815]: db_mongodb_store_result(): failed to set the columns
Nov  5 12:51:01 dev-rtpengine /usr/sbin/kamailio[21543]: ERROR: db_mongodb [mongodb_dbase.c:1018]: db_mongodb_query(): failed to store result
Nov  5 12:51:01 dev-rtpengine /usr/sbin/kamailio[21543]: ERROR: db_mongodb [mongodb_dbase.c:1027]: db_mongodb_query(): failed to do the query
Nov  5 12:51:01 dev-rtpengine /usr/sbin/kamailio[21543]: ERROR: usrloc [udomain.c:457]: preload_udomain(): db_query failed
Nov  5 12:51:01 dev-rtpengine /usr/sbin/kamailio[21543]: ERROR: usrloc [usrloc_mod.c:430]: child_init(): child(1): failed to preload domain 'location'
Nov  5 12:51:01 dev-rtpengine /usr/sbin/kamailio[21543]: ERROR: <core> [core/sr_module.c:946]: init_mod_child(): error while initializing module usrloc (/usr/lib64/kamailio/modules/usrloc.so) (idx: 1 rank: 1 desc: [udp receiver child=0 sock=10.10.10.10:5060])
Nov  5 12:51:01 dev-rtpengine /usr/sbin/kamailio[21543]: ERROR: <core> [core/pt.c:340]: fork_process(): init_child failed for process 1, pid 21543, "udp receiver child=0 sock=10.10.10.10:5060"
Nov  5 12:51:01 dev-rtpengine /usr/sbin/kamailio[21543]: CRITICAL: <core> [main.c:1607]: main_loop(): Cannot fork


2018-11-05T13:07:19.117+0100 D COMMAND  [conn367] run command kamailio.$cmd { find: "version", filter: { table_name: "location" }, projection: { table_version: 1 } }
2018-11-05T13:07:19.118+0100 I COMMAND  [conn367] command kamailio.version command: find { find: "version", filter: { table_name: "location" }, projection: { table_version: 1 } } planSummary: COLLSCAN keysExamined:0 docsExamined:2 cursorExhausted:1 numYields:0 nreturned:1 reslen:148 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 0ms
2018-11-05T13:07:19.118+0100 D COMMAND  [conn367] run command kamailio.$cmd { find: "location", filter: { username: "dummy_user" }, projection: { username: 1 } }
2018-11-05T13:07:19.119+0100 I COMMAND  [conn367] command kamailio.location command: find { find: "location", filter: { username: "dummy_user" }, projection: { username: 1 } } planSummary: COLLSCAN keysExamined:0 docsExamined:2 cursorExhausted:1 numYields:0 nreturned:1 reslen:155 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 0ms
2018-11-05T13:07:19.178+0100 D COMMAND  [conn368] run command kamailio.$cmd { find: "location", filter: {}, projection: { username: 1, contact: 1, expires: 1, q: 1, callid: 1, cseq: 1, flags: 1, cflags: 1, user_agent: 1, received: 1, path: 1, socket: 1, methods: 1, last_modified: 1, ruid: 1, instance: 1, reg_id: 1, server_id: 1, connection_id: 1, keepalive: 1 } }
2018-11-05T13:07:19.179+0100 I COMMAND  [conn368] command kamailio.location command: find { find: "location", filter: {}, projection: { username: 1, contact: 1, expires: 1, q: 1, callid: 1, cseq: 1, flags: 1, cflags: 1, user_agent: 1, received: 1, path: 1, socket: 1, methods: 1, last_modified: 1, ruid: 1, instance: 1, reg_id: 1, server_id: 1, connection_id: 1, keepalive: 1 } } planSummary: COLLSCAN keysExamined:0 docsExamined:2 cursorExhausted:1 numYields:0 nreturned:2 reslen:180 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 0ms



[root@dev-rtpengine kamailio]# kamailio -v
version: kamailio 5.1.6 (x86_64/linux) 7d1964
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 7d1964
compiled on 11:10:15 Nov  4 2018 with gcc 4.8.5




--

BR,
Denys Pozniak