PJSIP No Matching endpoint found + Failed to authenticate (inbound)

Hi,
I have a PJSIP trunk configured for inbound calls.
All works correctly when I identify trunk by IP, but show No Matching endpoint found + Failed to authenticate errors when trying to do otherwise.
I have to set up multiple trunks from same IP, same server.

There is a PJSIP log extract showing headers when placing inbound call:

[Jan 19 12:23:35] NOTICE[14723]: res_pjsip/pjsip_distributor.c:672 log_failed_request: Request ‘INVITE’ from ‘“3901119889883” <sip:3901119889883@46.37.5.154>’ failed for ‘46.37.5.154:5060’ (callid: 798d8ecc6b36b93934ac6abf00f280eb@46.37.5.154:5060) - No matching endpoint found [Jan 19 12:23:35] NOTICE[14723]: res_pjsip/pjsip_distributor.c:672 log_failed_request: Request ‘INVITE’ from ‘“3901119889883” <sip:3901119889883@46.37.5.154>’ failed for ‘46.37.5.154:5060’ (callid: 798d8ecc6b36b93934ac6abf00f280eb@46.37.5.154:5060) - Failed to authenticate <— Transmitting SIP response (512 bytes) to UDP:46.37.5.154:5060 —> SIP/2.0 401 Unauthorized Via: SIP/2.0/UDP 46.37.5.154:5060;rport=5060;received=46.37.5.154;branch=z9hG4bK192d0eaf Call-ID: 798d8ecc6b36b93934ac6abf00f280eb@46.37.5.154:5060 From: “3901119889883” <sip:3901119889883@46.37.5.154>;tag=as1d6eac5c To: <sip:23568@192.168.1.254>;tag=z9hG4bK192d0eaf CSeq: 105 INVITE WWW-Authenticate: Digest realm=“asterisk”,nonce=“1547897015/069057584ba3c4bc967eac0ca92d473e”,opaque=“7ee8c3ac79b76144”,algorithm=md5,qop=“auth” Server: Asterisk PBX 16.1.1 Content-Length: 0 <— Received SIP request (421 bytes) from UDP:46.37.5.154:5060 —> ACK sip:23568@192.168.1.254:5060 SIP/2.0 Via: SIP/2.0/UDP 46.37.5.154:5060;branch=z9hG4bK192d0eaf;rport Max-Forwards: 70 From: “3901119889883” <sip:3901119889883@46.37.5.154>;tag=as1d6eac5c To: <sip:23568@192.168.1.254:5060>;tag=z9hG4bK192d0eaf Contact: <sip:3901119889883@46.37.5.154:5060> Call-ID: 798d8ecc6b36b93934ac6abf00f280eb@46.37.5.154:5060 CSeq: 105 ACK User-Agent: MOR Softswitch Content-Length: 0

And there is my configuration:

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

[0697635473]
type=registration
transport=transport-udp
outbound_auth=0697635473
server_uri=sip:sip.1line.it
client_uri=sip:23568@sip.1line.it
transport=transport-udp
retry_interval=60
contact_user=23568

[0697635473]
type=auth
auth_type=userpass
password=*********
username=23568

[0697635473]
type=aor
contact=sip:sip.1line.it:5060

[0697635473]
type=endpoint
transport=transport-udp
context=from-0697635473
disallow=all
allow=ulaw
outbound_auth=0697635473
aors=0697635473
from_user=23568

Can someone help me out? Thanks in advance

I’ve never configured pjsip. Hower:

You have no identify section, and the endpoint section is named 0697635473, but the received From: user appears to be 3901119889883, which isn’t even close to a match.

Found myself that using a identify section in my pjsip.conf using a match_header option with a regex value for the to header was the solution.

1 Like

I haven’t seen match_header used before, can you show what you did?

If you have an outbound registration you can try using the line option[1] instead which may do away with the need for an identify section.

[1] https://blogs.asterisk.org/2016/01/27/the-pjsip-outbound-registration-line-option/