How to forward sip call on Asterisk using PJSIP?


I recently migrated our old server to new Asterisk with PJSIP, we are using database and AGI to control calls. Our customer can set up calls to either PSTN or Sip endpoints. In old sip server, we were using the following command in AGI.


Now for PJSIP I have changed following for my PSTN it is working perfectly, same string but for outbound Sip calls I am getting errors. As my PSTN trunk is registered so it is working,


It is giving me error

Unable to create PJSIP channel - endpoint '' was not found

I can fix it using pjsip.conf file and add this endpoint, but my issue is I have a huge number of endpoints in my database and there should be another solution, is it anything in configuration? as we don’t add these IPS in the system but just forward calls to another sip endpoint. And the user has the option to add more endpoints too. We are not using sip registration, neither allow sipper real-time user management.

Thanks for helping out.

You must always specify an endpoint in PJSIP, as it defines the configuration to use for the call. You can specify a SIP URI though with it[1]. You could create an endpoint named “outgoing” which defines the configuration and then reference it: PJSIP/outgoing/



Thank you, but what would be that configuration. I tried by adding following outgoing endpoint but am sure I am making some mistake, as I still get the error of registration of endpoint. Looks like either my configuration is adding more items, or maybe I am missing something.

type = aor
maximum_expiration = 60
minimum_expiration = 60
default_expiration = 180

type = identify
endpoint = outgoing

type = endpoint
context = default
dtmf_mode = none
disallow = all
allow = all
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
direct_media = no
language = en
aors = outgoing
t38_udptl = yes
t38_udptl_ec = none

But I am getting the following error in my CLI

Endpoint 'outgoing': Could not create a dialog to invalid URI ''.  Is endpoint registered and reachable?

I tried some more and now it is going out but it is saying I am not authenticated to send my call to server, but definitely I need some help in proper configuration of this outgoing.

I have also error my dialstring so now I my revised dialstring would be following

PJSIP/,30,HL(299940000:7000:5000) .  previous incorrect 

Do you need to authenticate to the server you are sending the call to? Did you have to do this before? There’s an example[1] on the wiki for authentication. There’s also a general page which links to PJSIP information, such as details about the different sections[2].

You also don’t need that “identify” section as it has nothing to match on. You also don’t need to specify “aors” or create an aor section as you aren’t using it.


Dear Jcolp, I already put your answer as solution and all is working now. Thanks btw I still remember you sitting on stage with your nice hat astricon 2017 as a programmer panel. Thank you.

1 Like