Sip registration with pjsip

Hi Guys,
Greetings!
I have recently set up asterisk server on the azure cloud, able to connect to sip provider (using sip module), and able to place a call successfully, thanks to all the support I found here/google/(asterisk definitive guide book).

Now, I am trying to replace sip module with pjsip (as it’s suggested in Asterisk Definitive Guide book). I tried the first step of registering to sip providers but after spending a lot of time (also tried using migration script sip_to_pjsip.py), couldn’t succeed.

Following was my sip.conf (obfuscated) which was working perfectly fine:

[general]
allowoverlap=no
udpbindaddr=0.0.0.0
tcpenable=yes
tcpbindaddr=0.0.0.0
transport=udp
srvlookup=yes
register=>+91XXXXXXXXXX@sip.example.com:mysecret:+91XXXXXXXXXX@sip.example.com@10.XX.XX.XX
externip=10.YY.YY.YY
localnet=192.168.0.0/16
localnet=127.0.0.1/32
nat=force_rport,comedia
externaddr=10.XX.XX.XX
maxexpiry=3600
registertimeout=3600
defaultexpiry=120

my pjsip.conf for the same which is not working (tried many combinations):

[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0
external_media_address = 10.XX.XX.XX (tried 10.YY.YY.YY too)
external_signaling_address = 10.XX.XX.XX (tried 10.YY.YY.YY too)
local_net = 192.168.0.0/16
local_net = 127.0.0.1/32
allow_reload = yes

[reg_sip]
type = registration
retry_interval = 3600
max_retries = 10
expiration = 3600
transport = transport-udp
outbound_auth = auth_reg_sip
client_uri = sip:+91XXXXXXXXXX@sip.example.com
server_uri = sip:sip.example.com
contact_user = +91XXXXXXXXXX
outbound_proxy=sip:10.XX.XX.XX (tried 10.YY.YY.YY too)

[auth_reg_sip]
type = auth
password = mysecret
username = +91XXXXXXXXXX@sip.example.com
realm=sip.example.com

while trying pjsip, I disabled sip module using module.conf. from my sip provider, I get 486 (busy here) error with pjsip but the same works fine with sip.

I will be really grateful if someone can guide me here. (I can also share packets transferred in both cases if needed)

Thanks in advance.

Networking Information My sip line is connected to a firewall where I have subnetted sip gateway and sip ips provided by sip line provider. From firewall to azure I have ipsec tunnel. all traffic from asterisk to sip line is supposed to be sent to 10.x.x.x ip which is then going to sip gateway. asterisk’s ip is natted to 10.y.y.y as expected by sip gateway.

Network packets when using chan_sip

REGISTER sip:sip.example.com SIP/2.0
Via: SIP/2.0/UDP 10.x.x.x:5060;branch=z9hG4bK0d332357;rport
Max-Forwards: 70
From: <sip:+91XXXXXXX@sip.example.com>;tag=as2a1980b7
To: <sip:+91XXXXXXX@sip.example.com>
Call-ID: 0405666d758444257e3670442735381b
CSeq: 105 REGISTER
Supported: replaces, timer
User-Agent: Asterisk PBX 16.12.0
Authorization: Digest username="+91XXXXXXX@sip.example.com", realm="sip.example.com", algorithm=MD5, uri="sip:sip.example.com", nonce="+lqaOT5Xr/KXvxXNUUUaVQ==", response="6097d0b2f61d310002465622f0955076", qop=auth, cnonce="2d5a8a71", nc=00000001
Expires: 3600
Contact: <sip:s@10.X.X.X:5060>
Content-Length: 0


---

<--- SIP read from UDP:10.X.X.X:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.X.X.X:5060;branch=z9hG4bK0d332357;received=10.Y.Y.Y;rport=22064
Call-ID: 0405666d758444257e3670442735381b
From: <sip:+91XXXXXXX@sip.example.com>;tag=as2a1980b7
To: <sip:+91XXXXXXX@sip.example.com>;tag=6n7xnh90
CSeq: 105 REGISTER
Accept-Resource-Priority: wps.4
P-Associated-URI: <sip:+91XXXXXXX@sip.example.com>..................
Contact: <sip:s@10.X.X.X:5060>;expires=3600
Content-Length: 0

when using pjsip

REGISTER sip:10.X.X.X SIP/2.0
Via: SIP/2.0/UDP 10.X.X.X:5060;rport;branch=z9hG4bKPjd27a3091-a69e-4f0f-b2ca-29d895da1a7c
From: <sip:+91XXXXXXX@sip.example.com>;tag=a1f75bef-2c0b-41b2-926e-2892a096d10e
To: <sip:+91XXXXXXX@sip.example.com>
Call-ID: 8d33f3bc-c2bb-41b8-8696-a679bfed1789
CSeq: 23673 REGISTER
Contact: <sip:+91XXXXXXX@10.X.X.X:5060>
Expires: 120
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Max-Forwards: 70
User-Agent: Asterisk PBX 16.12.0
Content-Length:  0


<--- Received SIP response (454 bytes) from UDP:10.X.X.X:5060 --->
SIP/2.0 486 Busy Here
Via: SIP/2.0/UDP 10.X.X.X:5060;branch=z9hG4bKPjd27a3091-a69e-4f0f-b2ca-29d895da1a7c;received=10.Y.Y.Y;rport=30949
Call-ID: 8d33f3bc-c2bb-41b8-8696-a679bfed1789
From: <sip:+91XXXXXXX@sip.example.com>;tag=a1f75bef-2c0b-41b2-926e-2892a096d10e
To: <sip:+91XXXXXXX@sip.example.com>;tag=bbdfvvyd
CSeq: 23673 REGISTER
Warning: 399 5122.2636.B.260.5.256.255.255.5640.0.0.sip.example.com "Server Busy"
Content-Length: 0

I found out the issue. My Voip provider is expecting domain in register string (so instead of. REGISTER sip:10.X.X.X SIP/2.0, it should be REGISTER sip:sip.example.com SIP/2.0) which is happening due to outbound_proxy I have set as sip:10.X.X.X. If I don’t do that, my requests itself are not reaching to my provider.
I don’t know how to resolve this.

You would want to enable loose routing:

outbound_proxy=sip:10.X.X.X\;lr

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