Help with pjsip config

Hello all
I am very new to asterisk, webrtc and SIP

I am trying asterisk and what I am doing here is I have a asterisk server running in an instance and I am trying to make SIP calls using pion webrtc client. So I have my pjsip configured as below

[general]
realm = 127.0.0.1

[1060]
username = 1060

[1061]
username = 1061

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Non mapped elements end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--;


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

[transport-ws]
type = transport
protocol = ws,wss
bind = 0.0.0.0

[1060]
type = aor
max_contacts = 1

[1060]
type = auth
username = 1060
password = password

[1060]
type = endpoint
context = default
ice_support = yes
direct_media = no
use_avpf = yes
auth = 1060
outbound_auth = 1060
media_encryption = dtls
dtls_verify = fingerprint
dtls_cert_file = /etc/asterisk/keys/asterisk.pem
dtls_setup = actpass
aors = 1060
transport = transport-ws

[1060]
type = registration
line = yes
server_uri = 1060:127.0.0.1
client_uri = 1060:hello@127.0.0.1
contact_user = 1060
endpoint = 1060
transport = transport-ws



[1061]
type = aor
max_contacts = 1

[1061]
type = auth
username = 1061
password = password

[1061]
type = endpoint
context = default
auth = 1061
outbound_auth = 1061
aors = 1061

Now I was able to connect to asterisk websocket, Now in the next step I am trying to register a endpoint

REGISTER sip:127.0.0.1:8089 SIP/2.0
Supported: path,ice
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
User-Agent: Pion WebRTC SIP Client
Contact: <sip:1060@127.0.0.1;transport=ws>;expires=200
Via: SIP/2.0/WS 127.0.0.1;branch=z9hG4bKab6773ab-99ec-4f9c-85b8-c2e1b3356046
To: <sip:1060@127.0.0.1>
Call-ID: 24110630-9a1c-4304-b19c-d4298c058fbd
From: <sip:1060@127.0.0.1>;tag=39d4758e-d8db-4e04-8bbf-8817d4d5c91a
Organization: ACE MEDIAS TOOLS
CSeq: 8082 REGISTER
Content-Length: 0
Max-Forwards: 70

When I try to write this message to websocket I get response as 401 and I don’t any log in asterisk CLI except on error client getting disconnected to websocket. I have a feeling that my pjsip.conf is not proper or the request is not sent correct.

Please help me. Thanks in advance

The only error I can see is that you haven’t removed the unmapped elements from the mechanical translation, but hopefully they are left in harmless places.

You will get 401 if you have auth= for the endpoint. The registrant is expected to authorise at that point. Has it been configured with a password?

So I am sending a REGISTER request first time with no auth and then I am making a follow up REGISTER request which is as follows

REGISTER sip:127.0.0.1:8089 SIP/2.0
Authorization: 02714cba4417b68ff356306e2e36bf56
Contact: <sip:webrtc_cleint@127.0.0.1;transport=ws>;expires=200
From: <sip:webrtc_client@127.0.0.1>;tag=af279f39-ec3c-4a76-942c-f819b350bf51
Organization: ACE MEDIAS TOOLS
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER, REGISTER
CSeq: 8083 REGISTER
Via: SIP/2.0/WS 127.0.0.1;branch=z9hG4bKde5fd9c5-7794-4b3f-b1f1-799cd255698c
To: <sip:webrtc_client@127.0.0.1>
Supported: path,ice
Call-ID: 900de452-dcf3-468c-a0c4-e5621d013682
User-Agent: Pion WebRTC SIP Client
Content-Length: 0
Max-Forwards: 70

I also changed the PJSIP config as per asterisk wiki guide to as follows

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

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


[webrtc_client]
type=aor
max_contacts=5
remove_existing=yes

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

[webrtc_client]
type=endpoint
aors=webrtc_client
auth=webrtc_client
dtls_auto_generate_cert=yes
webrtc=yes
context=default
disallow=all
allow=opus,ulaw

I am getting this error in console

sip_transport.c Error processing 649 bytes packet from WS 127.0.0.1:59040 : PJSIP syntax error exception when parsing 'Authorization' header on line 2 col -1:

May be I am not sending Authorization correctly here, but is there any specific format that I need to follow for Authorization. So I configured password in pjsip.conf so now how do I authorize the client with that password.

Followed this. It worked
Thank you

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