Help is needed. I know I have seen a similar problem either via email or google search but for the life of me I cannot find it now. 


I am using:

Ubuntu:

5.4.0-144-generic #161-Ubuntu SMP Fri Feb 3 14:49:04 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Kamailio:

version: kamailio 5.3.9 (x86_64/linux)  -- This is a dev platform and I can update kamailio if needed.



I am trying to query a mongodb collection for the phone number stored under “did” as an integer and make a decision based on the returned result (boolean is sufficient for this decision). 


I don’t know what I am doing wrong here. Any help will be well appreciated



##### This is the insert statement into the telephone db from a linux script

 db.c$coll.insertOne({"did":parseInt($(cut -d_ -f 1 <<< $1)), "callDesc":$(cut -d_ -f 1 <<< $1)}))" >> $(cut -d_ -f 1 <<< $1).js



did is stored as an integer and the callDesc is stored as presented by $rU


{ "_id" : ObjectId("641580b4863678d0ba38d69a"), "did" : 1XXXXXXXXXX, "callDesc" : 1XXXXXXXXXXXX }

> db.c234.find()

{ "_id" : ObjectId("641580b4863678d0ba38d69a"), "did" : 2XXXXXXXXXXXX, "callDesc" : 2XXXXXXXXXXXX }

> db.c234.find()

{ "_id" : ObjectId("641580b4863678d0ba38d69a"), "did" : 3XXXXXXXXXXXX, "callDesc" : 3XXXXXXXXXXXX }

> 



Kamailio config:

.....

.....


# --- mongodb module loaded 202201082322

loadmodule "ndb_mongodb.so"



 if (uri==myself) 

        {

                sl_send_reply("100", "Trying to check if uri is myself $rU $ru");

                #return;


                #Adding this to test connection to mongodb…. This worked and the reply was sent to the endpoint

                if(mongodb_cmd_simple("mongodbsrv1", "telephone", "cXXX”, "{ \"collStats\": \"cXXX\” }", "mgr1"))

                {

                        sl_send_reply("183", "I got inside this message loop $rU found in mongodb");

                        xlog("response from mongodb is [[$mongodb(mgr1=>value)]]\n");

                }

                # End of the test

#This is to run the actual db query to test if the phone number is in the mongodb…. I am not successful at this query even when the number is known to be in the database

                if(mongodb_find_one("mongodbsrv1", "telephone", "cXXX”, "{\"did\" : \"$rU\" }", "mongoResponse1"))

                {

                        # Route to confirmed route here -- 202302212032



                        sl_send_reply("183", "I got inside this mongodb message loop");

                        route(CONFIRMED_ROUTE);

                        xlog("response from mongodb is [[$mongodb(mongoResponse1=>value)]]\n");

                }

                else

                {

                        route(UNCONFIRMED_ROUTE);

                }

        }

        #append_hf("P-hint: outbound\r\n");

        route(RELAY);

        #exit;

}



Please help.

--
-----
Ekunwe
Tel: 601.497.3932