How to forward sip call on Asterisk using PJSIP?

0

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.

SIP/#######@sipserverip.com,30,HL(299940000:7000:5000)

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,

 PJSIP/#######@sipserverip.com,30,HL(299940000:7000:5000)

It is giving me error

Unable to create PJSIP channel - endpoint 'sipserverip.com' 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/sip:######@sipserverip.com

[1] https://wiki.asterisk.org/wiki/display/AST/Dialing+PJSIP+Channels

3 Likes

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.

[outgoing]
type = aor
maximum_expiration = 60
minimum_expiration = 60
default_expiration = 180

[outgoing]
type = identify
endpoint = outgoing

[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 '#####@sipserverip.com'.  Is endpoint registered and reachable?

UPDATE
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/#######@sipserverip.com,30,HL(299940000:7000:5000) .  previous incorrect 
PJSIP/outgoing/sip:#######@sipserverip.com,30,HL(299940000:7000:5000)

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.

[1] https://wiki.asterisk.org/wiki/display/AST/res_pjsip+Configuration+Examples
[2] https://wiki.asterisk.org/wiki/display/AST/Configuring+res_pjsip

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