Configuring Pjsip

I have just installed asterisk with pjsip.

I want to make a simple test but I get an error and I do not understand why

I had this working with chan_sip and I want to do the same with pjsip

BEFORE

sip.conf

[amp]
type=friend
host=10.60.164.33
port=50060
disallow=all
allow=ulaw
allow=alaw
dtmfmode=inband
insecure=invite
qualify=yes
context=public

extensions.conf

exten => _1XXX,1,Answer
       same => n,MusicOnHold()

NOW

pjsip.conf

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

[amp]
type=endpoint
transport=transport-udp
context=public
port=50060
disallow=all
allow=ulaw
aors=amp

[amp]
type=identify
endpoint=amp
contact=sip:8548@10.60.164.33:50060
match=10.60.164.33:50060

extensions.conf

exten => _1XXX,1,Answer
       same => n,MusicOnHold()

I get this error

[Aug 8 12:12:33] NOTICE[26708]: res_pjsip/pjsip_distributor.c:482 log_unidentified_request: Request from '<sip:10.60.164.33>' failed for '10.60.164.33:50060' (callid: 14dda332-34cb-48cc-a55f-26d673f43078) - No matching endpoint found

Can you explain what is wrong??

Contact is not valid for the identify type, and the identify is using IP address “10.60.164.13” while your request is coming from “10.60.164.33”.

changed ip to 33 no difference

And if you remove the port number as well? What is the console output at startup? Any problems noted with the configuration?

yes, I just noticed

[Aug 8 14:58:02] ERROR[27479]: config_options.c:715 aco_process_var: Could not find option suitable for category ‘amp’ named ‘contact’ at line 1048 of
[Aug 8 14:58:02] ERROR[27479]: res_sorcery_config.c:318 sorcery_config_internal_load: Could not create an object of type ‘identify’ with id ‘amp’ from configuration file ‘pjsip.conf’

I removed port 50060 from amp
My app listens on port 50060 btw

Just a note, to use that simple dialplan in chan_sip I did not have to configure anything in asterisk 11, what has changed since then?

chan_sip and chan_pjsip are two completely different implementations, each with their own configuration. You could have continued to use sip.conf and chan_sip if you wanted.

I am trying to learn pjsip… is it possible somehow to call this basic extension in pjsip

exten => _1XXX,1,Answer
same => n,MusicOnHold()

This to me seems to be protocol independent
How can make asterisk to answer a call and play an audio in pjsip?

Looking at the error

[Aug 8 14:58:06] NOTICE[27479]: res_pjsip/pjsip_distributor.c:482 log_unidentified_request: Request from '<sip:10.60.164.33>' failed for '10.60.164.33:50060' (callid: e5aad4ad-7fd6-43dd-8a55-3e628b0d90ad) - No matching endpoint found

No matching endpoint found

To me it seems that if the extension in the dialplan is not hard coded (assigned) to a device, asterisk is not capable of handling it

Is that a bad assumption?

The dialplan is completely independent of your pjsip.conf or sip.conf configuration.

The issue you are running into is that your pjsip.conf configuration is invalid. Things won’t work until you get that righted. As @jcolp pointed out, your identify configuration is invalid, and as a result, inbound requests aren’t being matched to the endpoint that you want.

Please provide the full configuration of your pjsip.conf, along with the ERROR messages you are getting when the configuration is processed.

This has nothing to do with the dialplan. Asterisk can’t match the inbound request to an endpoint, because you haven’t provided a valid pjsip.conf configuration to allow it to do that.

@mjordan thanks for your help

I have now deleted everything from the pjsip.conf file and reloaded the configuration

I have now only

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

localhost*CLI> pjsip reload 
Module 'res_pjsip.so' reloaded successfully.
Module 'res_pjsip_authenticator_digest.so' reloaded successfully.
Module 'res_pjsip_endpoint_identifier_ip.so' reloaded successfully.
Module 'res_pjsip_mwi.so' reloaded successfully.
Module 'res_pjsip_notify.so' reloaded successfully.
Module 'res_pjsip_outbound_publish.so' reloaded successfully.
Module 'res_pjsip_publish_asterisk.so' reloaded successfully.
Module 'res_pjsip_outbound_registration.so' reloaded successfully.
    -- Reloading module 'res_pjsip.so' (Basic SIP resource)
[Aug  8 15:40:40] NOTICE[23940]: sorcery.c:1388 sorcery_object_load: Type 'system' is not reloadable, maintaining previous values
    -- Reloading module 'res_pjsip_authenticator_digest.so' (PJSIP authentication resource)
    -- Reloading module 'res_pjsip_endpoint_identifier_ip.so' (PJSIP IP endpoint identifier)
    -- Reloading module 'res_pjsip_mwi.so' (PJSIP MWI resource)
    -- Reloading module 'res_pjsip_notify.so' (CLI/AMI PJSIP NOTIFY Support)
    -- Reloading module 'res_pjsip_outbound_publish.so' (PJSIP Outbound Publish Support)
    -- Reloading module 'res_pjsip_publish_asterisk.so' (PJSIP Asterisk Event PUBLISH Support)
    -- Reloading module 'res_pjsip_outbound_registration.so' (PJSIP Outbound Registration Support)
localhost*CLI> 

If I now make a call from my system

[Aug 8 15:41:23] NOTICE[23940]: res_pjsip/pjsip_distributor.c:482 log_unidentified_request: Request from '<sip:10.60.164.33>' failed for '10.60.164.33:50060' (callid: 1e12331e-8922-43c8-a3a7-22199eab70ff) - No matching endpoint found

I have just installed asterisk 13 for the first time, is there any config I need to adjust?

Well, that’s not really what I recommended, but okay :slight_smile:

I think you may need to read up on the documentation for how to configure PJSIP - see Home - Asterisk Documentation for where you should get started.

At a high level, you will need:

  • An endpoint. This defines the basic properties of the device that you are going to talk to, such as what formats it uses. It also ties other concepts the device may have together, such as the location of the device (managed by the aor settings) or how authentication is handled (managed by auth settings).

  • If you want to dial the device, or if the device registers with Asterisk, you’ll need an aor.

  • If you need to authenticate with the device, or if the device needs to authenticate with Asterisk, you’ll need auth section(s).

  • By default, inbound requests from the device will be mapped to the endpoint based on the user portion of the From URI. If that isn’t want you want, and you need to map requests based on the sending IP address, you’ll need to provide an identify section that tells Asterisk how to map an inbound request to the endpoint.

2 Likes

Thanks a lot

it took me a bit but it is now working

that is the config

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

[amp]
type=endpoint
transport=transport-udp
context=public
disallow=all
allow=ulaw
outbound_auth=amp
aors=amp

[amp]
type=aor
contact=sip:10.60.164:13:50060

[amp]
type=identify
endpoint=amp
match=10.60.164.13

Just as an aside, this tells Asterisk that when it sends a request to the amp endpoint, and if the amp endpoint challenges the request with a 401, we should use the authentication credentials in the amp auth object to authenticate.

Looking at the config you posted, however, I don’t see an auth object defined - which means that the challenge will result in the request failing.

If the endpoint challenges requests from Asterisk, you’ll need to define that as well.

Thanks a lot for all help!
for some reason after i remove the many
trunk-prime-id-xxxxxx00
endpoint = trunk-prime-endpoint-xxxxxx00

[trunk-prime-id-xxxxxx99](trunk-prime-id-tmpl)
endpoint = trunk-prime-endpoint-xxxxxx99

and then keep only the main endpoint the system is working normally. i dont know why but its working… There is one thing for sure. I need to check it a little bit more and create a proper configuration.

Thank you all for your help.
Kind Regards,
Marinos

after had a look all conversion , i understood that , we cannot separate calls to different context with port as we do in chan_sip or there is another way to do it?

There is not currently a mechanism to do that, no.