No matching endpoint found (realtime)

I am trying to establish communication between two Asterisk servers, attempting to simulate the scenario used by the PSTN.

On one side, there is a configuration in sip.conf that represents the PSTN.

On my side, I am configuring pjsip.conf.

The PSTN server has the IP address 172.16.1.31.
The server with PJSIP has the IP address 172.16.1.121.

The configurations on both sides are as follows:

PSTN

[pstn]
type=peer
context=saida-oi
canreinvite=no
dtmfmode=rfc2833
host=172.16.1.121
qualify=yes
nat=force_rport,comedia
disallow=all
allow=alaw,ulaw,g729

My side PJSIP

[pjsip]
type=endpoint
context=interno
disallow=all
allow=ulaw
direct_media=no
transport=transport-udp
aors=pjsip

[pjsip]
type=identify
endpoint=pjsip
match=172.16.1.31

[pjsip]
type=aor
contact=sip:172.16.1.31
qualify_frequency=60

With this configuration, I can make and receive calls without any issues.

I converted the PJSIP settings to realtime in PostgreSQL.

=# select id, transport, aors, context, disallow, allow, direct_media from ps_endpoints where id='pjsip';
  id   |   transport   | aors  | context | disallow | allow | direct_media
-------+---------------+-------+---------+----------+-------+--------------
 pjsip | transport-udp | pjsip | interno | all      | ulaw  | no
(1 registro)
=# select id, contact, qualify_frequency from ps_aors where id='pjsip';
  id   |     contact     | qualify_frequency
-------+-----------------+-------------------
 pjsip | sip:172.16.1.31 |                60
(1 registro)

With this configuration, I can make calls from PJSIP to the PSTN. However, I’m unable to receive calls from the PSTN and encountering this error:

[2023-05-24 18:10:28] NOTICE[12748]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '"asterisk" <sip:asterisk@172.16.1.31>' failed for '172.16.1.31:5060' (callid: 6c6c162672f7aa8c6bfac36142a7d3f2@172.16.1.31:5060) - No matching endpoint found

I believe the issue is that there is no table available for me to input the identify information.

[pjsip]
type=identify
endpoint=pjsip
match=172.16.1.31

Even if I add this code snippet to the pjsip.conf file, the problem remains the same.

When a reload is performed on the PSTN side, this message appears on my PJSIP server:

[2023-05-24 18:12:57] NOTICE[12748]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'OPTIONS' from '"asterisk" <sip:asterisk@172.16.1.31>' failed for '172.16.1.31:5060' (callid: 70227e9e7880528f20d5d2680ec034f6@172.16.1.31:5060) - No matching endpoint found

Where should I put this identify information, or how should the database settings be made to communicate with the PSTN using realtime?

I’m almost certain that the problem lies with the identify configuration because if I remove it and only use configurations in pjsip.conf, I still encounter the same error when using realtime.

Like this on pjsip.conf:

[pjsip]
type=endpoint
context=interno
disallow=all
allow=ulaw
direct_media=no
transport=transport-udp
aors=pjsip

[pjsip]
type=aor
contact=sip:172.16.1.31
qualify_frequency=60
[May 24 18:08:46] NOTICE[21446]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '"asterisk" <sip:asterisk@172.16.1.31>' failed for '172.16.1.31:5060' (callid: 6c213f7a24388e52667c9e313468d1d3@172.16.1.31:5060) - No matching endpoint found

You haven’t shown the full configurations. For now, pjsip set logger on should give you more clues as to what’s not working.

I ran the command pjsip set logger on in the console, and this is the output I get when I execute a sip reload on the PSTN server:

[May 25 10:25:10] <--- Received SIP request (532 bytes) from UDP:172.16.1.31:5060 --->
[May 25 10:25:10] OPTIONS sip:172.16.1.142 SIP/2.0
[May 25 10:25:10] Via: SIP/2.0/UDP 172.16.1.31:5060;branch=z9hG4bK767868b2;rport
[May 25 10:25:10] Max-Forwards: 70
[May 25 10:25:10] From: "asterisk" <sip:asterisk@172.16.1.31>;tag=as7c56df3b
[May 25 10:25:10] To: <sip:172.16.1.142>
[May 25 10:25:10] Contact: <sip:asterisk@172.16.1.31:5060>
[May 25 10:25:10] Call-ID: 1cac390b6e348ed15f8f90b42f16bbaa@172.16.1.31:5060
[May 25 10:25:10] CSeq: 102 OPTIONS
[May 25 10:25:10] User-Agent: Asterisk PBX 13.6.0
[May 25 10:25:10] Date: Thu, 25 May 2023 13:25:10 GMT
[May 25 10:25:10] Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
[May 25 10:25:10] Supported: replaces, timer
[May 25 10:25:10] Content-Length: 0
[May 25 10:25:10]
[May 25 10:25:10]
[2023-05-25 10:25:10] NOTICE[10626]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'OPTIONS' from '"asterisk" <sip:asterisk@172.16.1.31>' failed for '172.16.1.31:5060' (callid: 1cac390b6e348ed15f8f90b42f16bbaa@172.16.1.31:5060) - No matching endpoint found
[May 25 10:25:10] <--- Transmitting SIP response (496 bytes) to UDP:172.16.1.31:5060 --->
[May 25 10:25:10] SIP/2.0 401 Unauthorized
[May 25 10:25:10] Via: SIP/2.0/UDP 172.16.1.31:5060;rport=5060;received=172.16.1.31;branch=z9hG4bK767868b2
[May 25 10:25:10] Call-ID: 1cac390b6e348ed15f8f90b42f16bbaa@172.16.1.31:5060
[May 25 10:25:10] From: "asterisk" <sip:asterisk@172.16.1.31>;tag=as7c56df3b
[May 25 10:25:10] To: <sip:172.16.1.142>;tag=z9hG4bK767868b2
[May 25 10:25:10] CSeq: 102 OPTIONS
[May 25 10:25:10] WWW-Authenticate: Digest realm="asterisk",nonce="1685021110/41e353d25e8f6a3a5f9ac01122999912",opaque="389cc5cb05a0758b",algorithm=md5,qop="auth"
[May 25 10:25:10] Server: Asterisk PBX 16.4.0
[May 25 10:25:10] Content-Length:  0
[May 25 10:25:10]
[May 25 10:25:10]
[May 25 10:25:10] <--- Received SIP request (532 bytes) from UDP:172.16.1.31:5060 --->
[May 25 10:25:10] OPTIONS sip:172.16.1.142 SIP/2.0
[May 25 10:25:10] Via: SIP/2.0/UDP 172.16.1.31:5060;branch=z9hG4bK1fdedb0c;rport
[May 25 10:25:10] Max-Forwards: 70
[May 25 10:25:10] From: "asterisk" <sip:asterisk@172.16.1.31>;tag=as0545220b
[May 25 10:25:10] To: <sip:172.16.1.142>
[May 25 10:25:10] Contact: <sip:asterisk@172.16.1.31:5060>
[May 25 10:25:10] Call-ID: 720641a51a94a270417a8755500de0fb@172.16.1.31:5060
[May 25 10:25:10] CSeq: 102 OPTIONS
[May 25 10:25:10] User-Agent: Asterisk PBX 13.6.0
[May 25 10:25:10] Date: Thu, 25 May 2023 13:25:10 GMT
[May 25 10:25:10] Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
[May 25 10:25:10] Supported: replaces, timer
[May 25 10:25:10] Content-Length: 0
[May 25 10:25:10]
[May 25 10:25:10]
[2023-05-25 10:25:10] NOTICE[26589]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'OPTIONS' from '"asterisk" <sip:asterisk@172.16.1.31>' failed for '172.16.1.31:5060' (callid: 720641a51a94a270417a8755500de0fb@172.16.1.31:5060) - No matching endpoint found
[May 25 10:25:10] <--- Transmitting SIP response (496 bytes) to UDP:172.16.1.31:5060 --->
[May 25 10:25:10] SIP/2.0 401 Unauthorized
[May 25 10:25:10] Via: SIP/2.0/UDP 172.16.1.31:5060;rport=5060;received=172.16.1.31;branch=z9hG4bK1fdedb0c
[May 25 10:25:10] Call-ID: 720641a51a94a270417a8755500de0fb@172.16.1.31:5060
[May 25 10:25:10] From: "asterisk" <sip:asterisk@172.16.1.31>;tag=as0545220b
[May 25 10:25:10] To: <sip:172.16.1.142>;tag=z9hG4bK1fdedb0c
[May 25 10:25:10] CSeq: 102 OPTIONS
[May 25 10:25:10] WWW-Authenticate: Digest realm="asterisk",nonce="1685021110/41e353d25e8f6a3a5f9ac01122999912",opaque="79928a4c74a1abfe",algorithm=md5,qop="auth"
[May 25 10:25:10] Server: Asterisk PBX 16.4.0
[May 25 10:25:10] Content-Length:  0
[May 25 10:25:10]
[May 25 10:25:10]

This is the message that appears when I make a call from the PSTN (SIP) to the server with PJSIP:

[May 25 10:26:03] <--- Received SIP request (822 bytes) from UDP:172.16.1.31:5060 --->
[May 25 10:26:03] INVITE sip:1000@172.16.1.142 SIP/2.0
[May 25 10:26:03] Via: SIP/2.0/UDP 172.16.1.31:5060;branch=z9hG4bK36d33e1d;rport
[May 25 10:26:03] Max-Forwards: 70
[May 25 10:26:03] From: "asterisk" <sip:asterisk@172.16.1.31>;tag=as4f9073fa
[May 25 10:26:03] To: <sip:1000@172.16.1.142>
[May 25 10:26:03] Contact: <sip:asterisk@172.16.1.31:5060>
[May 25 10:26:03] Call-ID: 5dff6a3c5fec32503ab6499f6d8c7dcd@172.16.1.31:5060
[May 25 10:26:03] CSeq: 102 INVITE
[May 25 10:26:03] User-Agent: Asterisk PBX 13.6.0
[May 25 10:26:03] Date: Thu, 25 May 2023 13:26:03 GMT
[May 25 10:26:03] Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
[May 25 10:26:03] Supported: replaces, timer
[May 25 10:26:03] Content-Type: application/sdp
[May 25 10:26:03] Content-Length: 249
[May 25 10:26:03]
[May 25 10:26:03] v=0
[May 25 10:26:03] o=root 1026219145 1026219145 IN IP4 172.16.1.31
[May 25 10:26:03] s=Asterisk PBX 13.6.0
[May 25 10:26:03] c=IN IP4 172.16.1.31
[May 25 10:26:03] t=0 0
[May 25 10:26:03] m=audio 19616 RTP/AVP 8 101
[May 25 10:26:03] a=rtpmap:8 PCMA/8000
[May 25 10:26:03] a=rtpmap:101 telephone-event/8000
[May 25 10:26:03] a=fmtp:101 0-16
[May 25 10:26:03] a=ptime:20
[May 25 10:26:03] a=maxptime:150
[May 25 10:26:03] a=sendrecv
[May 25 10:26:03]
[2023-05-25 10:26:03] NOTICE[10626]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '"asterisk" <sip:asterisk@172.16.1.31>' failed for '172.16.1.31:5060' (callid: 5dff6a3c5fec32503ab6499f6d8c7dcd@172.16.1.31:5060) - No matching endpoint found
[May 25 10:26:03] <--- Transmitting SIP response (500 bytes) to UDP:172.16.1.31:5060 --->
[May 25 10:26:03] SIP/2.0 401 Unauthorized
[May 25 10:26:03] Via: SIP/2.0/UDP 172.16.1.31:5060;rport=5060;received=172.16.1.31;branch=z9hG4bK36d33e1d
[May 25 10:26:03] Call-ID: 5dff6a3c5fec32503ab6499f6d8c7dcd@172.16.1.31:5060
[May 25 10:26:03] From: "asterisk" <sip:asterisk@172.16.1.31>;tag=as4f9073fa
[May 25 10:26:03] To: <sip:1000@172.16.1.142>;tag=z9hG4bK36d33e1d
[May 25 10:26:03] CSeq: 102 INVITE
[May 25 10:26:03] WWW-Authenticate: Digest realm="asterisk",nonce="1685021163/67674301a991fd8cb26904c8d6726769",opaque="544ccd3572fbbf57",algorithm=md5,qop="auth"
[May 25 10:26:03] Server: Asterisk PBX 16.4.0
[May 25 10:26:03] Content-Length:  0
[May 25 10:26:03]
[May 25 10:26:03]
[May 25 10:26:03] <--- Received SIP request (397 bytes) from UDP:172.16.1.31:5060 --->
[May 25 10:26:03] ACK sip:1000@172.16.1.142 SIP/2.0
[May 25 10:26:03] Via: SIP/2.0/UDP 172.16.1.31:5060;branch=z9hG4bK36d33e1d;rport
[May 25 10:26:03] Max-Forwards: 70
[May 25 10:26:03] From: "asterisk" <sip:asterisk@172.16.1.31>;tag=as4f9073fa
[May 25 10:26:03] To: <sip:1000@172.16.1.142>;tag=z9hG4bK36d33e1d
[May 25 10:26:03] Contact: <sip:asterisk@172.16.1.31:5060>
[May 25 10:26:03] Call-ID: 5dff6a3c5fec32503ab6499f6d8c7dcd@172.16.1.31:5060
[May 25 10:26:03] CSeq: 102 ACK
[May 25 10:26:03] User-Agent: Asterisk PBX 13.6.0
[May 25 10:26:03] Content-Length: 0
[May 25 10:26:03]
[May 25 10:26:03]

You do not need a contact address in the AOR section and usually you would need an auth reference in the endpoint section. Since you have not given a full configuration, I don’t know whether this is going to help.

Is the res_pjsip_endpoint_identifier_ip module loaded?

Yes, it is.
sorcery.conf

[test_sorcery_section]
test=memory


[test_sorcery_cache]
test/cache=test
test=memory


[res_pjsip]
endpoint=realtime,ps_endpoints
auth=realtime,ps_auths
aor=realtime,ps_aors
domain_alias=realtime,ps_domain_aliases
contact=realtime,ps_contacts


[res_pjsip_endpoint_identifier_ip]
identify=realtime,ps_endpoint_id_ips


[res_pjsip_outbound_publish]
outbound-publish=realtime,ps_outbound_publishes


[res_pjsip_pubsub]
inbound-publication=realtime,ps_inbound_publications


[res_pjsip_publish_asterisk]
asterisk-publication=realtime,ps_asterisk_publications

modules.conf

[modules]
autoload=yes

;LOAD
load => app_confbridge.so

;NO LOAD
noload => chan_alsa.so
noload => chan_console.so
noload => res_hep.so
noload => res_hep_pjsip.so
noload => res_hep_rtcp.so
noload => pbx_ael.so
noload => pbx_lua.so
noload => res_parking.so
noload => chan_sip.so

extconfig.conf

[settings]
sippeers => odbc,anequim_config
extensions => odbc,anequim_config
psql_hints.conf => odbc,anequim_config,psql_hints_conf
psql_stdexten.conf => odbc,anequim_config,psql_stdexten_conf
users.conf => odbc,anequim_config,users_conf
confbridge.conf => odbc,anequim_config,confbridge
queue_log => odbc,anequim_cdr,queue_log
queues => odbc,anequim_config
queue_members => odbc,anequim_config
musiconhold => odbc,anequim_config
voicemail => odbc,anequim_config
extensions_queues.conf => odbc,anequim_config,extensions_queues_conf


;PJSIP
ps_endpoints => odbc,anequim_config
ps_auths => odbc,anequim_config
ps_aors => odbc,anequim_config
ps_domain_aliases => odbc,anequim_config
ps_endpoint_id_ips => odbc,anequim_config
ps_outbound_publishes => odbc,anequim_config
ps_inbound_publications = odbc,anequim_config
ps_asterisk_publications = odbc,anequim_config
ps_contacts = odbc,anequim_config
ps_registrations = odbc,anequim_config

I would suggest not using realtime first. Make things work in normal .conf files first, to eliminate the complexity that realtime adds to things. Only then move to realtime if you absolutely need to.

I successfully got it working in pjsip.conf as I mentioned earlier:

[pjsip]
type=endpoint
context=interno
disallow=all
allow=ulaw
direct_media=no
transport=transport-udp
aors=pjsip

[pjsip]
type=identify
endpoint=pjsip
match=172.16.1.31

[pjsip]
type=aor
contact=sip:172.16.1.31
qualify_frequency=60

The problem seems to be related to the values provided in the identify section because there is no specific table for it in the PJSIP configuration, and I haven’t identified a place to insert those values in the existing tables.

I already have the extensions (SIP endpoints) working with PJSIP, and now I need to get the trunks working as well. Since it’s not possible to have a mixed configuration of realtime and configuration files, I need everything to work through the database, in addition to all the versatility and maintainability possible through the use of a database.

Where and how should I place this part of the pjsip.conf file to be read through realtime?

[pjsip]
type=identify
endpoint=pjsip
match=172.16.1.31

I see now. In the pjsip.conf file, the type=identify section corresponds to the ps_endpoint_id_ips table in the database.

I was looking for related names, but now that I have filled the ps_endpoint_id_ips table, it’s working.

pjsip.conf

[pjsip]
type=identify
endpoint=pjsip
match=172.16.1.31

Converts to from ps_endpoint_id_ips:

=# select id, endpoint, match from ps_endpoint_id_ips where id='pjsip';
  id   | endpoint |    match
-------+----------+-------------
 pjsip | pjsip    | 172.16.1.31
(1 registro)

Thanks @jcolp.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.