Freepbx DID issue in outgoing


The outbound INVITE (lines 822 - 851 of your paste) does not contain the P-Preferred-Identity header that TATA requires, so they rejected the call (paste lines 870 - 878).

The word ‘Identity’ does not appear anywhere in your paste, so whatever code you may have used to add that header apparently did not get executed.

A good way to add the header is with a predial hook; see

Sample code to go in /etc/asterisk/extensions_custom.conf (not tested) could be something like:

exten => s,1,Noop(Adding caller ID for TATA)
exten => s,n,SipAddHeader(P-Preferred-Identity: <sip:6614100@>)
exten => s,n,MacroExit()

Restart Asterisk after modifying the file.

If no luck, look at the SIP trace to see whether P-Asserted-Identity is being properly added.

If you still have trouble, paste a new log.

(India) #22

But will this code overrides the CID configured in trunk? as I want DID of an extension to go out as CID. below is logic what TATA shared with me to dial out a CID


exten => _7X.,1,SipAddHeader(P-Preferred-Identity: <sip:6614100@>) à Please add the P-preferred-Identity header

exten => _7X.,2,Set(CALLERID(num)=6614101) à 6614101 would be the DID no. to be displayed…

exten => _7X.,3,Progress()

exten => _7X.,4,Dial(SIP/0${EXTEN:1}@tatasip)

exten => _7X.,5,Hangup()

(India) #23

Thanks Stewart the code is working and I am also getting different mapped DID on outgoing however I am not getting incoming calls.

below is the context which was given by TATA.

exten => _X.,1,Goto(s,1)

exten => s,1,Noop(Let us look deeper into the soul of the invite)
exten => s,n,Set(pseudodid=${SIP_HEADER(To)})
exten => s,n,Set(pseudodid=${CUT(pseudodid,@,1)})
exten => s,n,Set(pseudodid=${CUT(pseudodid,:,2)})
exten => s,n,Goto(from-pstn,${pseudodid},1)

(India) #24

log below for incoming not reachable.


I don’t know why your tata context isn’t working. Try changing context for your trunk:
Restart Asterisk and retest. Paste another log if you still have trouble.

(India) #26

Thanks Stewart its working, I changed the context to above given by you will do all testing and let you know if I face any issues anyways thanks again. cheers

Sorry Stewart its working i messed up with inbound routes, now everything is working.

(India) #27

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

(India) #28

hello Stewart I just need one last help what is happening now if my Trunk ISP gateway is not reachable due to their downtime freepbx sends register request but after few attempts if trunk is not reachable it fails and after that freepbx is not able to restart the registration request.

if there anyway that freepbx should keep on checking a heartbeat of trunk.



Unless you have set the registerattempts (chan_sip) or Max Retries (pjsip) parameter, it should retry indefinitely. You can confirm this with sngrep or tcpdump. Possibly, the retries are being blocked by the router or provider, or something related to the error causes them to be blocked by fail2ban (check whether the IP gets banned).

(India) #30

It retries for about 89 times and then it fails.

(India) #31

Hello Stewart I am just struggling in dialing plan as below.

I am not able to dial 7 digit dialing plan, I can add a prepend for local code but cant dial 7 digit if I am dialing out of state, how can make 7 digit dialing work

(India) #32


(India) #33

Can you check the log below my local 7 digit dialing is not working.