CallerID Lookup Module not working correctly?

Hello all,
I have an asterisk 1.4 installation on CentOS and Latest version of FreePBX (2.5.1.0)

I have attempted to install a localized php lookup program (Superfecta .php from Nerd Vittles) for incoming CallerID lookup from my SIP account(s).

For whatever reason, the information (CID Name) is not being passed to the internal phones, nor is it showing up in CDR on my logs (the number is, but not the “friendly name”). Only the CID number that is being passed from my provider.

Here is a snippet of my log for the CallerID lookup:
I have replaced the real numbers and names to protect the innocent :slight_smile:

Connected to Asterisk 1.4.21.2 currently running on asterisk-pbx (pid = 4535)
Verbosity is at least 3
– Executing [[email protected]:1] Set(“SIP/name-b7d08230”, “__FROM_DID=1231231234”) in new stack
– Executing [[email protected]:2] Gosub(“SIP/name-b7d08230”, “app-blacklist-check|s|1”) in new stack
– Executing [[email protected]:1] LookupBlacklist(“SIP/name-b7d08230”, “”) in new stack
– Executing [[email protected]:2] GotoIf(“SIP/name-b7d08230”, “0?blacklisted”) in new stack
– Executing [[email protected]:3] Return(“SIP/name-b7d08230”, “”) in new stack
– Executing [[email protected]:3] Gosub(“SIP/name-b7d08230”, “cidlookup|cidlookup_6|1”) in new stack
– Executing [[email protected]:1] GotoIf(“SIP/name-b7d08230”, “0?cidlookup|cidlookup_return|1”) in new stack
– Executing [[email protected]:2] Set(“SIP/name-b7d08230”, “CALLERID(name)=”) in new stack
– Executing [[email protected]:3] Set(“SIP/name-b7d08230”, “DB(cidname/1232232234)=”) in new stack
– Executing [[email protected]:4] Return(“SIP/name-b7d08230”, “”) in new stack
– Executing [[email protected]:4] GotoIf(“SIP/name-b7d08230”, “0 ?cidok”) in new stack
– Executing [[email protected]:5] Set(“SIP/name-b7d08230”, “CALLERID(name)=1232232234”) in new stack
– Executing [[email protected]:6] NoOp(“SIP/name-b7d08230”, “CallerID is “1232232234” <1232232234>”) in new stack
– Executing [[email protected]:7] Set(“SIP/name-b7d08230”, “__CALLINGPRES_SV=allowed_not_screened”) in new stack
– Executing [[email protected]:8] SetCallerPres(“SIP/name-b7d08230”, “allowed_not_screened”) in new stack
– Executing [[email protected]:9] Goto(“SIP/name-b7d08230”, “from-did-direct|3001|1”) in new stack
– Goto (from-did-direct,3001,1)
– Executing [[email protected]:1] GotoIf(“SIP/name-b7d08230”, “0?ext-local|3001|1”) in new stack
– Executing [[email protected]:2] Macro(“SIP/name-b7d08230”, “user-callerid|”) in new stack
– Executing [[email protected]:1] Set(“SIP/name-b7d08230”, “AMPUSER=1232232234”) in new stack
– Executing [[email protected]:2] GotoIf(“SIP/name-b7d08230”, “0?report”) in new stack
– Executing [[email protected]:3] ExecIf(“SIP/name-b7d08230”, “1|Set|REALCALLERIDNUM=1232232234”) in new stack
– Executing [[email protected]:4] Set(“SIP/name-b7d08230”, “AMPUSER=”) in new stack
– Executing [[email protected]:5] Set(“SIP/name-b7d08230”, “AMPUSERCIDNAME=”) in new stack
– Executing [[email protected]:6] GotoIf(“SIP/name-b7d08230”, “1?report”) in new stack
– Goto (macro-user-callerid,s,11)
– Executing [[email protected]:11] GotoIf(“SIP/name-b7d08230”, “0?continue”) in new stack
– Executing [[email protected]:12] Set(“SIP/name-b7d08230”, “__TTL=64”) in new stack
– Executing [[email protected]:13] GotoIf(“SIP/name-b7d08230”, “1?continue”) in new stack
– Goto (macro-user-callerid,s,20)
– Executing [[email protected]:20] NoOp(“SIP/name-b7d08230”, “Using CallerID “1232232234” <1232232234>”) in new stack
– Executing [[email protected]:3] GotoIf(“SIP/name-b7d08230”, “1?skipdb”) in new stack
– Goto (from-did-direct,3001,5)

Can anyone give me direction on why this is not working?
I have applied the CIDLOOKUP to my inbound routes

when I run the script from a web browser (which is loaded locally on asterisk) I can query a number and it returns a valid named response, but it is not showing up on my phones…
Does anyone have experience with this problem?

Thank You

Here:

Executing [[email protected]:3] Set("SIP/name-b7d08230", "DB(cidname/1232232234)=") in new stack

the code do a call to the internal cid lookup from the astdb database.
To see if you have entries do this from the console:

asterisk -r
database show cidname

Here you have the cidlookup database, if you don’t have any entries here, well, then there will be no lookup.

Thank you for your reply.
When I run that command on the internal database, It does show the CallerID, but without the name showing up to the associated number.
For example:
123-123-1234 (is coming over as 123-123-1234)
I am attempting to get extended information about that number using the http lookup source.

123-123-1234 (MR. Smith)

My question is that I have loaded the php pages correctly, and when I query them from a borwser, I get the extended CallerID information I am looking for, But when I get an incoming call, the only thing I am getting is the base number.

My question is should there be anything else I need to do other than create the http lookup and apply that lookup entry to the incoming route?

You log does not look right:

-- Executing [[email protected]:3] Gosub("SIP/name-b7d08230", "cidlookup|cidlookup_6|1") in new stack
-- Executing [[email protected]:1] GotoIf("SIP/name-b7d08230", "0?cidlookup|cidlookup_return|1") in new stack
-- Executing [[email protected]:2] Set("SIP/name-b7d08230", "CALLERID(name)=") in new stack
-- Executing [[email protected]:3] Set("SIP/name-b7d08230", "DB(cidname/1232232234)=") in new stack
-- Executing [[email protected]:4] Return("SIP/name-b7d08230", "") in new stack

It does only look as you have entered the Internal as your source for CID Lookup Source in your inbound route as the call is for DB(cidname…
If I enter a new CallerID Lookup Source and set up a bogus http, my section for cidlookup in extension_additional.conf look like this:

[cidlookup]
include => cidlookup-custom
exten => cidlookup_1,1,LookupCIDName
exten => cidlookup_1,n,Return()
exten => cidlookup_2,1,Set(CALLERID(name)=${CURL(http://name:[email protected]:80/test.php?get)})
exten => cidlookup_2,n,Return()
exten => cidlookup_return,1,LookupCIDName
exten => cidlookup_return,n,Return()

Look in your extension_additional.conf in section for cidlookup and see how that section looks like and if it does a call for CURL in cidlookup_6.

Thank you again for taking your time and looking at this for me…

[cidlookup]
include => cidlookup-custom
exten => cidlookup_6,1,GotoIf($[${DB_EXISTS(cidname/${CALLERID(num)})} = 1]?cidlookup,cidlookup_return,1)
exten => cidlookup_6,n,Set(CALLERID(name)=${CURL(http://localhost:80/callerid.php?thenumber=${CALLERID(num)})})
exten => cidlookup_6,n,Set(DB(cidname/${CALLERID(num)})=${CALLERID(name)})
exten => cidlookup_6,n,Return()
exten => cidlookup_return,1,LookupCIDName
exten => cidlookup_return,n,Return()

; end of [cidlookup]

What do you make of this?

It tells me that you have enabled the cache for the cid lookup as the first line checks if the entry exist in the local astdb database. If it does, it goes to the second last line and do a local lookup skipping the http lookup.

If you remove the check mark for cache (I cant remember the exact phrase as I don’t have a system in front of me) it will not do a local lookup and go straight to the http lookup.

I went ahead and made the change you suggested. Low and behold things did change…unfortunately I did not get the external CID, but I did get an error now that makes a little more sense?

[Oct 25 00:13:35] VERBOSE[3336] logger.c: – Executing [[email protected]:3] Gosub(“SIP/mgear-094697d8”, “cidlookup|cidlookup_6|1”) in new stack
[Oct 25 00:13:35] ERROR[3336] pbx.c: Function CURL not registered
[Oct 25 00:13:35] VERBOSE[3336] logger.c: – Executing [[email protected]:1] Set(“SIP/mgear-094697d8”, “CALLERID(name)=”) in new stack
[Oct 25 00:13:35] VERBOSE[3336] logger.c: – Executing [[email protected]:2] Return(“SIP/mgear-094697d8”, “”) in new stack
[Oct 25 00:13:35] VERBOSE[3336] logger.c: – Executing [[email protected]:4] GotoIf(“SIP/mgear-094697d8”, “0 ?cidok”) in new stack
[Oct 25 00:13:35] VERBOSE[3336] logger.c: – Executing [[email protected]:5] Set(“SIP/mgear-094697d8”, “CALLERID(name)=3302818252”) in new stack

So I see that it says that function CURL is not registered.
I am assuming this is a function of the Asterisk libraries, but after some googling, I do not see how to “enable” this function…

I did create from source, so did I miss something when I compiled?
Is there a way that I can “manually” register CURL?

the version I have on my system is:
curl --version
curl 7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

Any further help would be appreciated…and once again, thank you for your time up to this point

Upon further digging, I found out that for whatever reason, on my first attempt to compile Asterisk, the func_curl.so was never compiled. I’m not sure if it was that curl-devel was not installed, or what…

I recompiled asterisk, making sure that func_curl.so was compiled correctly, and now everything is working like a champ!

Thanks for your time and helping me find my errors along the way!

Thank you for your feedback. I am glad that you got it sorted out.

Thank you for your help with this!
Just to follow-up this is exactly what I did:
Receiving error when I enabled an http Lookup.
I had cache results enabled within my CID lookup entry on FreePBX management page.
I removed this to fix the first error of the local database only being queried.
My second problem, after turning that off was the following error when placing an inbound call and having the verbosity set to 5

ERROR[3336] pbx.c: Function CURL not registered

Looking at my installed RPMs, I found that curl-devel was not installed.

I installed curl-devel:
yum -y install curl-devel

I then recompiled Asterisk:

make clean

make

make menuselect
(entries were the same from my original install)

make install

The .so file that I was missing was func_curl.so

After compiling, the func_curl.so was present.

amportal start

http lookup started working