We have a gateway (Asterisk SVN-branch-1.8-r313142) to handle all our gateway traffic we would like to route calls within a cretin area code with a specific LRN results to a specific carrier so we want to set in LCR field, the following works fine however sometimes the LRN lookup provider is lagging and in puts latency on calls, so I’m wonder if it is possible to add a timeout either on the Gosub get-lrn and it will go to the next priority if there is no response when timeout or it should set lrn blank and move on at timeout
exten => _+1212NXXXXXX,1,Gosub(get-lrn,${EXTEN},1)
exten => _+1NXXNXXXXXX,1,Gosub(to-main-carrier,${EXTEN},1)
where
[get-lrn]
exten => _+1NXXNXXXXXX,1,Set(LRN=${CURL(http://lrn.domain.com/api/lrn/lookup&number=1${EXTEN:-10})})
exten => _+1NXXNXXXXXX,n,gotoif($["${LRN" = "12125551212"]?lrn:main)
;back to main
;when main lcr is changed update here
exten => _+1NXXNXXXXXX,n(main),Gosub(to-main-carrier,${EXTEN},1)
exten => _+1NXXNXXXXXX,n,Return
;to lrn provider
exten => _+1NXXNXXXXXX,n(lrn),Gosub(to-lrn-carrier,${EXTEN},1)
exten => _+1NXXNXXXXXX,n,Return
Any help is greatly appreciated
Thanks eeman, will try to
Thanks eeman, will try to play with it the next few day s will keep you updated
my advice is to push that functionality to a php script or some other AGI language you are more familiar with and allow that to keep track of it. In fact since you are using curl, it probably wouldnt take too much modification of my callerid AGI tool to store LRN data and maintain a cache inside mysql so that you dont have to repeatedly lookup the same carrier for the same did over and over again. Even if you set the cache to only be valid for 10 days thats probably still going to be a big savings in time.