Calls with CID Lookup not reaching destination

My FreePBX installation is working fine, with one exception:

When I try to add CID lookup, the incoming call just rings and rings and never reaches the destination extension. The CNAM provider shows the request in the CDR and there are no errors, but that’s it. When I remove the CID lookup from the inbound route, the call rings through to the extension just fine.

Here is the log for the entire call (these four lines repeat over and over while it rings - 12345551212 is not the real number):

[font=Courier]
– Executing [12345551212@from-trunk:1] Set(“SIP/Flowroute-0000001e”, “__FROM_DID=12345551212”) in new stack
– Executing [12345551212@from-trunk:2] Gosub(“SIP/Flowroute-0000001e”, “cidlookup,cidlookup_1,1()”) in new stack
– Executing [cidlookup_1@cidlookup:1] GotoIf(“SIP/Flowroute-0000001e”, “0?cidlookup,cidlookup_return,1”) in new stack
– Executing [cidlookup_1@cidlookup:2] Set(“SIP/Flowroute-0000001e”, “CURLOPT(httptimeout)=7”) in new stack
[/font]

Any help would be greatly appreciated.

Thanks

If it helps, this is the contents of the [cidlookup] section in extensions_additional.conf:

[cidlookup]
include => cidlookup-custom
exten => cidlookup_1,1,GotoIf($[${DB_EXISTS(cidname/${CALLERID(num)})} = 1]?cidlookup,cidlookup_return,1)
exten => cidlookup_1,n,Set(CURLOPT(httptimeout)=7)
exten => cidlookup_1,n,Set(CALLERID(name)=${CURL(http://cnam.bulkcnam.com:80/index.php?id=myverylongandprivateid&did=${CALLERID(num)})})
exten => cidlookup_1,n,Set(DB(cidname/${CALLERID(num)})=${CALLERID(name)})
exten => cidlookup_1,n,Return()

exten => cidlookup_return,1,ExecIf($["${DB(cidname/${CALLERID(num)})}" != “”]?Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})}))
exten => cidlookup_return,n,Return()

I’ve been digging deeper. I tried programming it manually into extensions_custom.conf. It seems that it stops processing the dial plan as soon as the dial plan hits any CURL call and just keeps looping back to the beginning every few seconds. Asterisk was compiled with curl and curl exists (and works fine) on the server. Still no error messages…

The funny thing is CURL is in fact hitting the remote server (as per the remote server logs) - it just doesn’t seem to return the data to Asterisk.