Trouble with Kamailio + Asterisk: SIP works, but WebRTC REGISTER fails

Hello, everyone I’m having some troble with 2 endpoints, I’m currently trying to setup kamailio as a media proxy that accepts both sip and webrtc, but having some problems in endpoints, I’m using dispatcher to asterisk ‘1 sip:{{ AST_IP }}:5060 0 0 weight=10 maxload=1000’ and sending ping OPTIONS, this works fine and sip also but when I try to connect using webrtc I get this

1 sip:{{ AST_IP }}:5060 0 0 weight=10 maxload=1000

Kamailio sends OPTIONS pings to Asterisk, and that part works fine. SIP clients also register and make calls without issues.

However, when I try to connect using WebRTC (SIP.js), I get the following REGISTER request on Asterisk:

<--- Received SIP request (668 bytes) from UDP:10.5.0.8:5001 --->
REGISTER sip:172.31.217.74 SIP/2.0
Via: SIP/2.0/UDP 10.5.0.8:5001;branch=z9hG4bKd8fc.e84f464d9bd601be4b18355ce858c830.0
Via: SIP/2.0/WSS 03akq6mk8fc9.invalid;rport=51530;received=172.31.208.1;branch=z9hG4bK5127906
To: sip:User1@172.31.217.74
From: sip:User1@172.31.217.74;tag=oanei0udnm
CSeq: 2 REGISTER
Call-ID: o8s6a1erqaank9sqkcet
Max-Forwards: 69
Contact: sip:5gpf16av@03akq6mk8fc9.invalid;transport=ws;expires=600
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: outbound, path, gruu
User-Agent: SIP.js/0.21.1
Content-Length: 0
X-WSS-Source: kamailio
X-Original-Protocol: WSS
X-Original-From-Domain: 172.31.217.74

But Asterisk throws this warning:

WARNING[53]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR ‘’ not found for endpoint ‘kamailio’ (10.5.0.8:5001)

Despite that, I already have the following WebRTC-enabled endpoint in Asterisk (pjsip.conf)

[User1](basic_endpoint,webrtc_endpoint)
type=endpoint
callerid="User One" <1000>
auth=User1
aors=User1
force_rport=yes
rewrite_contact=yes

[User1](multi_aor)
mailboxes=User1@default

[User1](userpass_auth)
type=auth
username=User1
password=1234
realm=xxxxx

Meanwhile, regular SIP clients like 6001 work just fine. Here’s their config (working example):

INVITE sip:100@localhost;transport=tcp SIP/2.0
Via: SIP/2.0/TCP 172.31.208.1:51639;rport;branch=z9hG4bKPje43109e625bc417ca5e5e162dbfd093c;alias
Max-Forwards: 70
From: "6001" sip:6001@localhost;tag=ce7f2052edc34c9c8e90437ef46a5b9b
To: sip:100@localhost
Contact: sip:6001@172.31.208.1:51639;transport=TCP;ob;+sip.ice
Call-ID: c1e184265a344cf5ba4348f232a58b20
CSeq: 22999 INVITE
[6001]
type=endpoint
context=public
disallow=all
allow=g722
allow=ulaw
auth=6001
aors=6001
{% if NAT == 'true' %}
transport=transport-tcp-nat
force_rport=yes
ice_support=yes
rewrite_contact=yes
{% else %}
transport=transport-tcp
{% endif %}

[6001]
type=auth
auth_type=userpass
password=password
username=6001

[6001]
type=aor
max_contacts=10

Thank you for any help.

The incoming traffic was matched as being from “kamailio”, which you haven’t provided any configuration details for in PJSIP. If you are using IP based matching, then it would have likely matched before any other endpoints.

If you want to match based on username first instead then you would alter the matching order[1].

[1] asterisk/configs/samples/pjsip.conf.sample at master · asterisk/asterisk · GitHub

Yeah, I’m sorry.
I’m matching with IP:

[kamailio]
type=endpoint
transport=transport-udp-nat
context=public
disallow=all
allow=ulaw,alaw
aors=kamailio
direct_media=no

[kamailio]
type=aor
max_contacts=1

[kamailio]
type=identify
endpoint=kamailio
match=10.5.0.8