SOLVED: Problem with registering ('identify' seems to be the problem)

This is my complete pjsip.conf file:

[global]
type=global
endpoint_identifier_order=username,auth_username,ip


;; Snom
[snom_ip_identify]
type=identify
endpoint=snom_trunk
match=%LOCALNET%

[snom_auth]
type=auth
auth_type=userpass
password=12345
username=snom
realm=asterisksnom

[snom_trunk]
type=endpoint
transport=transport-udp
context=test
allow=all
auth=snom_auth
aors=200

;; Call PJSIP/snom_trunk/200
[200]
type=aor
max_contacts=10
remove_existing=true


;; Cisco
[cisco_ip_identify]
type=identify
endpoint=cisco_trunk
match=%LOCALNET%

[cisco_auth]
type=auth
auth_type=userpass
password=12345
username=cisco
realm=asteriskcisco

[cisco_trunk]
type=endpoint
transport=transport-udp
context=test
allow=all
auth=cisco_auth
aors=100

;; Call PJSIP/cisco_trunk/100
[100]
type=aor
max_contacts=10
remove_existing=true

Registering 100 works, but at 200 Asterisk returns asteriskcisco instead of asterisksnom as realm. I’m sure it has something to do with my identify sections, they both match the request.

Unforunately I’ve no idea how to fix the issue.

Thanks in advance!

In addition: Sometimes after changing the config and restarting Asterisk it logs

Unable to find persistent endpoint 'just renamed' for contact 'xxx'

What does it mean?

How would you determine from which peer the REGISTER was coming by looking at the request itself?

The remote ip address is surely an important indication. Afterwards I would check the username in the From header. I believe endpoint_identifier_order represents it. Do you advert to the fact that I need endpoints [100] and [200]?

You’ve specified the same IP address for both, so how is Asterisk going to be able to distinguish based on IP address?

(I’m not sure whether Asterisk requires disjoint sets of addresses, or operates some sort of most specific match test, but, either way, exactly the same set is always going to fail to resolve them properly.

Asterisk requires separate addresses in order to match them in the above configuration, or else only one will always match. The From user would need to match an endpoint and it seemingly isn’t.

Thanks! What do you think about this config, @jcolp ?

; Cisco
[cisco_endpoint](!)
type=endpoint
transport=transport-udp
context=test
allow=all

[cisco_auth]
type=auth
auth_type=userpass
password=12345
username=cisco
realm=asteriskcisco

[cisco_aor](!)
type=aor
max_contacts=10
remove_existing=true


[100](cisco_endpoint)
auth=cisco_auth
aors=100
[100](cisco_aor)

[101](cisco_endpoint)
auth=cisco_auth
aors=101
[101](cisco_aor)

Seems fine? Not knowing precisely what the traffic looks like and the configuration of the remote party I can’t really say how things will work with it, but provided the From user is matched and authentication is configured the same then it would work.

Where does Asterisk store persistent endpoints? Can this feature be disabled?

They are an internal in memory storage mechanism, they can’t be disabled. I haven’t seen any reports of the message you’ve seen, what version of Asterisk are you using?

I’m using version 15.1.3 and the report looks like this:

WARNING: res_pjsip/pjsip_options.c:1402 contact_update_endpoint_state: Unable to find persistent endpoint 'xxx' for contact 'xxxxxx'

Can you reproduce it easily? If so please file an issue[1] with details of how to reproduce it.

[1] https://issues.asterisk.org/jira