Hello,
I using Asterisk with PJSIP. I have connected sip trunk and successfully received incoming calls.
When I try to call outside to the trunk, I get 503 service unavailable error. But, if I use zoiper desktop application, it works fine. I have attached the tcpdump of zoiper outgoing call.
My sip provider doesn’t have documentation for Asterisk, and I am on my own. So, I would be grateful if anyone could help me this.
Here is my pjsip.conf:
...
[mobicom]
type=registration
outbound_auth=mobicom
outbound_proxy=sip:202.131.248.20:5090
server_uri=sip:mobileoffice.mn
client_uri=sip:+97675097474200@mobileoffice.mn
retry_interval=60
[mobicom]
type=aor
contact=sip:mobileoffice.mn:5060
outbound_proxy=sip:202.131.248.20:5090
[mobicom]
type=auth
auth_type=userpass
username=+97675097474200@mobileoffice.mn
password=SECRET_PASSWORD
[mobicom]
type=endpoint
transport=transport-tcp
context=from-external
disallow=all
allow=ulaw
outbound_auth=mobicom
aors=mobicom
[mobicom]
type=identify
endpoint=mobicom
match=202.131.248.0/24
...
Here is my extensions.conf:
...
[outgoing]
exten => _X.,1,Set(CALLERID(num)=+97675097474200)
same => n,Dial(PJSIP/${EXTEN}@mobicom)
same => n,Hangup()
[from-extensions]
exten => _XXXXXXXX,1,NoOp(${EXTEN})
same => n,Goto(outgoing,${EXTEN},1)
...
Here is the pjsip log during outgoing call:
<--- Received SIP request (921 bytes) from TCP:66.181.161.1:55904 --->
INVITE sip:80771559@asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---b09a95114a61c5ed;rport
Max-Forwards: 70
Contact: <sip:500@66.181.161.1:55904;transport=TCP>
To: <sip:80771559@asterisk.domain.com>
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=0dfc5f01
Call-ID: MJ0_pVa5PmEIR2SSP2ZTmA..
CSeq: 1 INVITE
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Content-Type: application/sdp
User-Agent: Z 5.5.13 v2.10.18.3
Allow-Events: presence, kpml, talk
Content-Length: 326
v=0
o=Z 0 350897267 IN IP4 172.20.10.2
s=Z
c=IN IP4 172.20.10.2
t=0 0
m=audio 8000 RTP/AVP 106 9 98 101 0 8 3
a=rtpmap:106 opus/48000/2
a=fmtp:106 sprop-maxcapturerate=16000; minptime=20; useinbandfec=1
a=rtpmap:98 telephone-event/48000
a=fmtp:98 0-16
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
<--- Transmitting SIP response (528 bytes) to TCP:66.181.161.1:55904 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/TCP 172.20.10.2:63080;rport=55904;received=66.181.161.1;branch=z9hG4bK-524287-1---b09a95114a61c5ed
Call-ID: MJ0_pVa5PmEIR2SSP2ZTmA..
From: <sip:500@asterisk.domain.com>;tag=0dfc5f01
To: <sip:80771559@asterisk.domain.com>;tag=z9hG4bK-524287-1---b09a95114a61c5ed
CSeq: 1 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1663266961/c9080266341a0628112d2373d4f9b25a",opaque="1cee79153b9f2553",algorithm=MD5,qop="auth"
Server: Asterisk PBX 18.12.1
Content-Length: 0
<--- Received SIP request (391 bytes) from TCP:66.181.161.1:55904 --->
ACK sip:80771559@asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---b09a95114a61c5ed;rport
Max-Forwards: 70
To: <sip:80771559@asterisk.domain.com>;tag=z9hG4bK-524287-1---b09a95114a61c5ed
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=0dfc5f01
Call-ID: MJ0_pVa5PmEIR2SSP2ZTmA..
CSeq: 1 ACK
Content-Length: 0
<--- Received SIP request (1233 bytes) from TCP:66.181.161.1:55904 --->
INVITE sip:80771559@asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---8e751359808b9ff0;rport
Max-Forwards: 70
Contact: <sip:500@66.181.161.1:55904;transport=TCP>
To: <sip:80771559@asterisk.domain.com>
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=0dfc5f01
Call-ID: MJ0_pVa5PmEIR2SSP2ZTmA..
CSeq: 2 INVITE
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Content-Type: application/sdp
User-Agent: Z 5.5.13 v2.10.18.3
Authorization: Digest username="500",realm="asterisk",nonce="1663266961/c9080266341a0628112d2373d4f9b25a",uri="sip:80771559@asterisk.domain.com;transport=TCP",response="839db9e643936f9dd1764c7349a65aca",cnonce="5d13be9550f5afee1ac182b8033dee87",nc=00000001,qop=auth,algorithm=MD5,opaque="1cee79153b9f2553"
Allow-Events: presence, kpml, talk
Content-Length: 326
v=0
o=Z 0 350897267 IN IP4 172.20.10.2
s=Z
c=IN IP4 172.20.10.2
t=0 0
m=audio 8000 RTP/AVP 106 9 98 101 0 8 3
a=rtpmap:106 opus/48000/2
a=fmtp:106 sprop-maxcapturerate=16000; minptime=20; useinbandfec=1
a=rtpmap:98 telephone-event/48000
a=fmtp:98 0-16
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
<--- Transmitting SIP response (336 bytes) to TCP:66.181.161.1:55904 --->
SIP/2.0 100 Trying
Via: SIP/2.0/TCP 172.20.10.2:63080;rport=55904;received=66.181.161.1;branch=z9hG4bK-524287-1---8e751359808b9ff0
Call-ID: MJ0_pVa5PmEIR2SSP2ZTmA..
From: <sip:500@asterisk.domain.com>;tag=0dfc5f01
To: <sip:80771559@asterisk.domain.com>
CSeq: 2 INVITE
Server: Asterisk PBX 18.12.1
Content-Length: 0
-- Executing [80771559@from-extensions:1] NoOp("PJSIP/500-00000054", "80771559") in new stack
-- Executing [80771559@from-extensions:2] Goto("PJSIP/500-00000054", "outgoing,80771559,1") in new stack
-- Goto (outgoing,80771559,1)
-- Executing [80771559@outgoing:1] Set("PJSIP/500-00000054", "CALLERID(num)=+97675097474200") in new stack
-- Executing [80771559@outgoing:2] Dial("PJSIP/500-00000054", "PJSIP/80771559@mobicom") in new stack
-- Called PJSIP/80771559@mobicom
== Everyone is busy/congested at this time (1:0/1/0)
-- Executing [80771559@outgoing:3] Hangup("PJSIP/500-00000054", "") in new stack
== Spawn extension (outgoing, 80771559, 3) exited non-zero on 'PJSIP/500-00000054'
<--- Transmitting SIP response (414 bytes) to TCP:66.181.161.1:55904 --->
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/TCP 172.20.10.2:63080;rport=55904;received=66.181.161.1;branch=z9hG4bK-524287-1---8e751359808b9ff0
Call-ID: MJ0_pVa5PmEIR2SSP2ZTmA..
From: <sip:500@asterisk.domain.com>;tag=0dfc5f01
To: <sip:80771559@asterisk.domain.com>;tag=4356d496-2935-455b-91cf-6a3e8406c66f
CSeq: 2 INVITE
Server: Asterisk PBX 18.12.1
Reason: Q.850;cause=34
Content-Length: 0
<--- Received SIP request (392 bytes) from TCP:66.181.161.1:55904 --->
ACK sip:80771559@asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---8e751359808b9ff0;rport
Max-Forwards: 70
To: <sip:80771559@asterisk.domain.com>;tag=4356d496-2935-455b-91cf-6a3e8406c66f
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=0dfc5f01
Call-ID: MJ0_pVa5PmEIR2SSP2ZTmA..
CSeq: 2 ACK
Content-Length: 0
<--- Received SIP request (906 bytes) from TCP:66.181.161.1:55905 --->
REGISTER sip:asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---d22cf340ce44234e;rport
Max-Forwards: 70
Contact: <sip:500@66.181.161.1:55904;transport=TCP;rinstance=7e065c528020b302>;expires=0
To: <sip:500@asterisk.domain.com;transport=TCP>
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=89c17e48
Call-ID: VDFJonqsICjy5gnmvmL1Ag..
CSeq: 3 REGISTER
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Z 5.5.13 v2.10.18.3
Authorization: Digest username="500",realm="asterisk",nonce="1663266935/daf2d9c27dc35b036b9b03664dd303b5",uri="sip:asterisk.domain.com;transport=TCP",response="b3c746a650a523d7d740c2b130d458a8",cnonce="3a852f678536017e2beead3ad6f127a4",nc=00000002,qop=auth,algorithm=MD5,opaque="36dc7b73299a24c7"
Allow-Events: presence, kpml, talk
Content-Length: 0
== Contact 500/sip:500@66.181.161.1:55904;transport=TCP;rinstance=7e065c528020b302 has been deleted
== Endpoint 500 is now Unreachable
-- Removed contact 'sip:500@66.181.161.1:55904;transport=TCP;rinstance=7e065c528020b302' from AOR '500' due to request
<--- Transmitting SIP response (406 bytes) to TCP:66.181.161.1:55905 --->
SIP/2.0 200 OK
Via: SIP/2.0/TCP 172.20.10.2:63080;rport=55905;received=66.181.161.1;branch=z9hG4bK-524287-1---d22cf340ce44234e
Call-ID: VDFJonqsICjy5gnmvmL1Ag..
From: <sip:500@asterisk.domain.com>;tag=89c17e48
To: <sip:500@asterisk.domain.com>;tag=z9hG4bK-524287-1---d22cf340ce44234e
CSeq: 3 REGISTER
Date: Thu, 15 Sep 2022 18:36:02 GMT
Server: Asterisk PBX 18.12.1
Content-Length: 0
<--- Received SIP request (606 bytes) from TCP:66.181.161.1:55905 --->
REGISTER sip:asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---13854787e725dbb4;rport
Max-Forwards: 70
Contact: <sip:500@172.20.10.2:63080;rinstance=f3e9e7d4f821ab47;transport=tcp>
To: <sip:500@asterisk.domain.com;transport=TCP>
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=621a9522
Call-ID: nXMApIkD_Y7vflTXp0RABA..
CSeq: 1 REGISTER
Expires: 600
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Z 5.5.13 v2.10.18.3
Allow-Events: presence, kpml, talk
Content-Length: 0
<--- Transmitting SIP response (525 bytes) to TCP:66.181.161.1:55905 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/TCP 172.20.10.2:63080;rport=55905;received=66.181.161.1;branch=z9hG4bK-524287-1---13854787e725dbb4
Call-ID: nXMApIkD_Y7vflTXp0RABA..
From: <sip:500@asterisk.domain.com>;tag=621a9522
To: <sip:500@asterisk.domain.com>;tag=z9hG4bK-524287-1---13854787e725dbb4
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1663266963/a273ee502206b69013aa24a152e013fb",opaque="7fca183516927c45",algorithm=MD5,qop="auth"
Server: Asterisk PBX 18.12.1
Content-Length: 0
<--- Received SIP request (909 bytes) from TCP:66.181.161.1:55905 --->
REGISTER sip:asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---2c55e920eb5fe4b3;rport
Max-Forwards: 70
Contact: <sip:500@172.20.10.2:63080;rinstance=f3e9e7d4f821ab47;transport=tcp>
To: <sip:500@asterisk.domain.com;transport=TCP>
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=621a9522
Call-ID: nXMApIkD_Y7vflTXp0RABA..
CSeq: 2 REGISTER
Expires: 600
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Z 5.5.13 v2.10.18.3
Authorization: Digest username="500",realm="asterisk",nonce="1663266963/a273ee502206b69013aa24a152e013fb",uri="sip:asterisk.domain.com;transport=TCP",response="74d6e4a141fe6e62ec806eb2d37d9701",cnonce="4b056aba8d937960f7fc4da8f3659740",nc=00000001,qop=auth,algorithm=MD5,opaque="7fca183516927c45"
Allow-Events: presence, kpml, talk
Content-Length: 0
-- Added contact 'sip:500@172.20.10.2:63080;transport=tcp;rinstance=f3e9e7d4f821ab47' to AOR '500' with expiration of 600 seconds
<--- Transmitting SIP response (511 bytes) to TCP:66.181.161.1:55905 --->
SIP/2.0 200 OK
Via: SIP/2.0/TCP 172.20.10.2:63080;rport=55905;received=66.181.161.1;branch=z9hG4bK-524287-1---2c55e920eb5fe4b3
Call-ID: nXMApIkD_Y7vflTXp0RABA..
From: <sip:500@asterisk.domain.com>;tag=621a9522
To: <sip:500@asterisk.domain.com>;tag=z9hG4bK-524287-1---2c55e920eb5fe4b3
CSeq: 2 REGISTER
Date: Thu, 15 Sep 2022 18:36:03 GMT
Contact: <sip:500@172.20.10.2:63080;transport=tcp;rinstance=f3e9e7d4f821ab47>;expires=599
Expires: 600
Server: Asterisk PBX 18.12.1
Content-Length: 0
== Endpoint 500 is now Reachable
<--- Received SIP request (905 bytes) from TCP:66.181.161.1:55905 --->
REGISTER sip:asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---eac06882e3d4d145;rport
Max-Forwards: 70
Contact: <sip:500@172.20.10.2:63080;transport=tcp;rinstance=f3e9e7d4f821ab47>;expires=0
To: <sip:500@asterisk.domain.com;transport=TCP>
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=621a9522
Call-ID: nXMApIkD_Y7vflTXp0RABA..
CSeq: 3 REGISTER
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Z 5.5.13 v2.10.18.3
Authorization: Digest username="500",realm="asterisk",nonce="1663266963/a273ee502206b69013aa24a152e013fb",uri="sip:asterisk.domain.com;transport=TCP",response="f0e1ec762ba959e6bef1a7746f879add",cnonce="699f0a05f5a2b69c2c104aca52e74d7b",nc=00000002,qop=auth,algorithm=MD5,opaque="7fca183516927c45"
Allow-Events: presence, kpml, talk
Content-Length: 0
-- Removed contact 'sip:500@172.20.10.2:63080;transport=tcp;rinstance=f3e9e7d4f821ab47' from AOR '500' due to request
<--- Transmitting SIP response (406 bytes) to TCP:66.181.161.1:55905 --->
SIP/2.0 200 OK
Via: SIP/2.0/TCP 172.20.10.2:63080;rport=55905;received=66.181.161.1;branch=z9hG4bK-524287-1---eac06882e3d4d145
Call-ID: nXMApIkD_Y7vflTXp0RABA..
From: <sip:500@asterisk.domain.com>;tag=621a9522
To: <sip:500@asterisk.domain.com>;tag=z9hG4bK-524287-1---eac06882e3d4d145
CSeq: 3 REGISTER
Date: Thu, 15 Sep 2022 18:36:04 GMT
Server: Asterisk PBX 18.12.1
Content-Length: 0
== Contact 500/sip:500@172.20.10.2:63080;transport=tcp;rinstance=f3e9e7d4f821ab47 has been deleted
== Endpoint 500 is now Unreachable
<--- Received SIP request (607 bytes) from TCP:66.181.161.1:55905 --->
REGISTER sip:asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---6c72d043d1164667;rport
Max-Forwards: 70
Contact: <sip:500@66.181.161.1:55905;transport=TCP;rinstance=c513ad88e0e76ac9>
To: <sip:500@asterisk.domain.com;transport=TCP>
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=bdb03977
Call-ID: IEcfhRK8-KCtWp8sHUWqpA..
CSeq: 1 REGISTER
Expires: 600
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Z 5.5.13 v2.10.18.3
Allow-Events: presence, kpml, talk
Content-Length: 0
<--- Transmitting SIP response (525 bytes) to TCP:66.181.161.1:55905 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/TCP 172.20.10.2:63080;rport=55905;received=66.181.161.1;branch=z9hG4bK-524287-1---6c72d043d1164667
Call-ID: IEcfhRK8-KCtWp8sHUWqpA..
From: <sip:500@asterisk.domain.com>;tag=bdb03977
To: <sip:500@asterisk.domain.com>;tag=z9hG4bK-524287-1---6c72d043d1164667
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1663266965/04f57a4bf48b4339ba2a49e8ab4ceb15",opaque="5d6b625609ef5b32",algorithm=MD5,qop="auth"
Server: Asterisk PBX 18.12.1
Content-Length: 0
<--- Received SIP request (910 bytes) from TCP:66.181.161.1:55905 --->
REGISTER sip:asterisk.domain.com;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 172.20.10.2:63080;branch=z9hG4bK-524287-1---7141639e2ea79e3c;rport
Max-Forwards: 70
Contact: <sip:500@66.181.161.1:55905;transport=TCP;rinstance=c513ad88e0e76ac9>
To: <sip:500@asterisk.domain.com;transport=TCP>
From: <sip:500@asterisk.domain.com;transport=TCP>;tag=bdb03977
Call-ID: IEcfhRK8-KCtWp8sHUWqpA..
CSeq: 2 REGISTER
Expires: 600
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Z 5.5.13 v2.10.18.3
Authorization: Digest username="500",realm="asterisk",nonce="1663266965/04f57a4bf48b4339ba2a49e8ab4ceb15",uri="sip:asterisk.domain.com;transport=TCP",response="34a144c4c6e9e5027fc12c216e1b1a97",cnonce="546f503bf9e1d35192fb9adb011893e5",nc=00000001,qop=auth,algorithm=MD5,opaque="5d6b625609ef5b32"
Allow-Events: presence, kpml, talk
Content-Length: 0
-- Added contact 'sip:500@66.181.161.1:55905;transport=TCP;rinstance=c513ad88e0e76ac9' to AOR '500' with expiration of 600 seconds
<--- Transmitting SIP response (512 bytes) to TCP:66.181.161.1:55905 --->
SIP/2.0 200 OK
Via: SIP/2.0/TCP 172.20.10.2:63080;rport=55905;received=66.181.161.1;branch=z9hG4bK-524287-1---7141639e2ea79e3c
Call-ID: IEcfhRK8-KCtWp8sHUWqpA..
From: <sip:500@asterisk.domain.com>;tag=bdb03977
To: <sip:500@asterisk.domain.com>;tag=z9hG4bK-524287-1---7141639e2ea79e3c
CSeq: 2 REGISTER
Date: Thu, 15 Sep 2022 18:36:05 GMT
Contact: <sip:500@66.181.161.1:55905;transport=TCP;rinstance=c513ad88e0e76ac9>;expires=599
Expires: 600
Server: Asterisk PBX 18.12.1
Content-Length: 0
== Endpoint 500 is now Reachable
Here you can see the zoiper tcpdump: