PJSIP trunk outgoing call not working

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:

I don’t fully understand why it thinks there is no way of reaching the destination, but I believe chan_pjsip requires an explicit loose routing parameter on the proxy, if you want it to send the final destination address in the INVITE.

Thank you so much for your response.

I’ve changed my config as following:

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
external_media_address=PUBLIC_IP
external_signaling_address=PUBLIC_IP

[transport-tcp]
type=transport
protocol=tcp
bind=0.0.0.0
local_net=PRIVATE_IP
external_media_address=PUBLIC_IP
external_signaling_address=PUBLIC_IP
...
[600]
type=endpoint 
transport=transport-tcp
context=from-extensions
disallow=all 
allow=ulaw,alaw 
auth=600 
aors=600
direct_media=no
rtp_symmetric=yes
force_rport=yes

[600]
type=aor 
max_contacts=1
[600]
type=auth 
auth_type=userpass
username=600
password=SECRET_PASSWORD
...
[mobicom]
type=registration
outbound_auth=mobicom
outbound_proxy=sip:202.131.248.20:5090\;lr
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\;lr
[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
;g722,gms
outbound_auth=mobicom
outbound_proxy=sip:202.131.248.20:5090\;lr
aors=mobicom
[mobicom]
type=identify
endpoint=mobicom
match=202.131.248.0/24

600 is the extension initiating the outgoing call. mobicom is the trunk.

And here is the debug log during outgoing call:
debug-log.txt (59.9 KB)

Could you figure out what is going wrong? Do you need further information?

In the debug log file, I see this error

Source address 103.80.211.50:58652 does not match identify ‘mobicom’

I think it is matching my softphone IP to sip trunk identify section. Is there anything wrong with mobicom trunk identify section?

Response is 403 Forbidden

Nothing obviously syntactically wrong.

202.131.248.0/24 obviously won’t match 103.80.211.50

1 Like

You can try adding “from_user=+97675097474200” to the mobicom endpoint. That would make the INVITE From username match that of Zoiper.

1 Like

Okay, I have added from_user, from_domain fields in pjsip.conf to make the request same to that of zoiper :

...
[mobicom]
type=endpoint
transport=transport-tcp
context=from-external
disallow=all
allow=ulaw,alaw
outbound_auth=mobicom
outbound_proxy=sip:202.131.248.20:5090\;lr
bind_rtp_to_media_address=yes
from_user=+97675097474200
from_domain=mobileoffice.mn\;transport=TCP
aors=mobicom
...

The zoiper request look like this:

Frame 197: 988 bytes on wire (7904 bits), 988 bytes captured (7904 bits)
Ethernet II, Src: Apple_10:a2:cb (50:ed:3c:10:a2:cb), Dst: Tp-LinkT_aa:1e:44 (98:da:c4:aa:1e:44)
Internet Protocol Version 4, Src: 10.0.1.131, Dst: 202.131.248.20
Transmission Control Protocol, Src Port: 50243, Dst Port: 5090, Seq: 1, Ack: 1, Len: 922
Session Initiation Protocol (INVITE)
    Request-Line: INVITE sip:80771559@mobileoffice.mn;transport=TCP SIP/2.0
        Method: INVITE
        Request-URI: sip:80771559@mobileoffice.mn;transport=TCP
            Request-URI User Part: 80771559
            Request-URI Host Part: mobileoffice.mn
        [Resent Packet: False]
    Message Header
        Via: SIP/2.0/TCP 10.0.1.131:54767;branch=z9hG4bK-524287-1---6fd2f30c1123e9b1;rport
        Max-Forwards: 70
        Contact: <sip:+97675097474200@103.80.211.50:54767;transport=TCP>
        To: <sip:80771559@mobileoffice.mn>
        From: <sip:+97675097474200@mobileoffice.mn;transport=TCP>;tag=8f510a22
        Call-ID: APwxO80-bkSSoVa-Fr80_w..
        [Generated Call-ID: APwxO80-bkSSoVa-Fr80_w..]
        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: 330
    Message Body
        Session Description Protocol
            Session Description Protocol Version (v): 0
            Owner/Creator, Session Id (o): Z 0 322567226 IN IP4 103.80.211.50
            Session Name (s): Z
            Connection Information (c): IN IP4 103.80.211.50
            Time Description, active time (t): 0 0
            Media Description, name and address (m): audio 8000 RTP/AVP 106 9 98 101 0 8 3
            Media Attribute (a): rtpmap:106 opus/48000/2
            Media Attribute (a): fmtp:106 sprop-maxcapturerate=16000; minptime=20; useinbandfec=1
            Media Attribute (a): rtpmap:98 telephone-event/48000
            Media Attribute (a): fmtp:98 0-16
            Media Attribute (a): rtpmap:101 telephone-event/8000
            Media Attribute (a): fmtp:101 0-16
            Media Attribute (a): sendrecv
            [Generated Call-ID: APwxO80-bkSSoVa-Fr80_w..]

And, my pjsip log looks like this:

INVITE sip:80771559@mobileoffice.mn:5060 SIP/2.0
Via: SIP/2.0/TCP 18.220.96.228:5060;rport;branch=z9hG4bKPjd4f53b88-5ab9-4b50-bc3b-8393786b6568;alias
From: <sip:+97675097474200@mobileoffice.mn;transport=TCP>;tag=c268f95f-9c8c-44b2-a7cf-993d20b6716a
To: <sip:80771559@mobileoffice.mn>
Contact: <sip:+97675097474200@18.220.96.228:5060;transport=TCP>
Call-ID: e950a6f3-9273-4dd5-8f3e-ddfba1d83f5e
CSeq: 13889 INVITE
Route: <sip:202.131.248.20:5090;lr>
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 18.12.1
Content-Type: application/sdp
Content-Length:   259

v=0
o=- 21743935 21743935 IN IP4 18.220.96.228
s=Asterisk
c=IN IP4 18.220.96.228
t=0 0
m=audio 17190 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<--- Received SIP response (375 bytes) from TCP:202.131.248.20:5090 --->
SIP/2.0 100 Trying
Via: SIP/2.0/TCP 18.220.96.228:5060;received=18.220.96.228;branch=z9hG4bKPjd4f53b88-5ab9-4b50-bc3b-8393786b6568;alias;rport=50417
From: <sip:+97675097474200@mobileoffice.mn;transport=TCP>;tag=c268f95f-9c8c-44b2-a7cf-993d20b6716a
To: <sip:80771559@mobileoffice.mn>
Call-ID: e950a6f3-9273-4dd5-8f3e-ddfba1d83f5e
CSeq: 13889 INVITE
Content-Length: 0


<--- Received SIP response (406 bytes) from TCP:202.131.248.20:5090 --->
SIP/2.0 403 Forbidden
Via: SIP/2.0/TCP 18.220.96.228:5060;received=18.220.96.228;branch=z9hG4bKPjd4f53b88-5ab9-4b50-bc3b-8393786b6568;alias;rport=50417
From: <sip:+97675097474200@mobileoffice.mn;transport=TCP>;tag=c268f95f-9c8c-44b2-a7cf-993d20b6716a
To: <sip:80771559@mobileoffice.mn>;tag=aprqngfrt-jdho54300gd24
Call-ID: e950a6f3-9273-4dd5-8f3e-ddfba1d83f5e
CSeq: 13889 INVITE
Content-Length: 0


<--- Transmitting SIP request (488 bytes) to TCP:202.131.248.20:5090 --->
ACK sip:80771559@mobileoffice.mn:5060 SIP/2.0
Via: SIP/2.0/TCP 18.220.96.228:5060;rport;branch=z9hG4bKPjd4f53b88-5ab9-4b50-bc3b-8393786b6568;alias
From: <sip:+97675097474200@mobileoffice.mn;transport=TCP>;tag=c268f95f-9c8c-44b2-a7cf-993d20b6716a
To: <sip:80771559@mobileoffice.mn>;tag=aprqngfrt-jdho54300gd24
Call-ID: e950a6f3-9273-4dd5-8f3e-ddfba1d83f5e
CSeq: 13889 ACK
Route: <sip:202.131.248.20:5090;lr>
Max-Forwards: 70
User-Agent: Asterisk PBX 18.12.1
Content-Length:  0


  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [80771559@outgoing:3] Hangup("PJSIP/500-00000000", "") in new stack
  == Spawn extension (outgoing, 80771559, 3) exited non-zero on 'PJSIP/500-00000000'
<--- Transmitting SIP response (404 bytes) to UDP:66.181.179.76:6632 --->
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 192.168.1.2:64358;rport=6632;received=66.181.179.76;branch=z9hG4bK-524287-1---2ae0849c9d13b1fe
Call-ID: j9G0vOu9MO0xuGp8tR3ozw..
From: <sip:500@asterisk.monosolution.co>;tag=99ff984f
To: <sip:80771559@asterisk.monosolution.co>;tag=f0266d47-87ba-4e6d-bf7e-0de4ca92fb6d
CSeq: 2 INVITE
Server: Asterisk PBX 18.12.1
Reason: Q.850;cause=21
Content-Length:  0


<--- Received SIP request (392 bytes) from UDP:66.181.179.76:6632 --->
ACK sip:80771559@asterisk.monosolution.co;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.1.2:64358;branch=z9hG4bK-524287-1---2ae0849c9d13b1fe;rport
Max-Forwards: 70
To: <sip:80771559@asterisk.monosolution.co>;tag=f0266d47-87ba-4e6d-bf7e-0de4ca92fb6d
From: <sip:500@asterisk.monosolution.co;transport=UDP>;tag=99ff984f
Call-ID: j9G0vOu9MO0xuGp8tR3ozw..
CSeq: 2 ACK
Content-Length: 0

Could you tell me do you recognize anything odd?

Is it possible that you are being blocked by user agent (maybe they only accept phones), or IP address, which isn’t on the same network. Maybe they only accept traffic from network blocks used by mobile phone operators.

I can’t get a web page for them, so I can’t find rules.

Ah, it could be. I will clarify about this from the sip provider, and post back here if I get a concrete answer.

Anyway, thank you so much for your support. @jcolp and @david551

Okay, I’ve contacted with my SIP provider. They asked me to use SIP instead of PJSIP.

Since SIP is no longer supported, I don’t want to switch from PJSIP to SIP completely and use SIP for endpoints.

Could you tell me is there any problems with using both PJSIP and SIP (SIP for only outgoing calls and PJSIP for endpoints)? At least is there any problems in the long run from your experience?

@jcolp @david551

There is no issue running as such.

1 Like

You need to ensure they bind to different local ports (or different local interfaces), as you cannot have two sockets listening on the exactly the same address.

Please also try to use the terms chan_sip and chan_pjsip, as both implement SIP; in fact chan_pjsip tends to implement it better than chan_sip.

Providers saying use chan_sip is an easy cop out. Most of their suggested configurations for it are actually somewhat broken, so they are unlikely to really understand what they are asking, and unless they are specific about what is incompatible with they system supporting it in chan_pjsip will never get done.

Known issues are that while neither officially supports TEL: URIs, chan_sip doesn’t reject; them; and that, I believe, chan_pjsip doesn’t support short form headers. Partial support of TEL: should be arriving soon.

I think people have identified unusual usages of SIP, by providers, that can only be worked round with chan_sip, but a search of the forum, and a subsequent request, never produced any of them, so they may well not get addressed.

1 Like

The chan_pjsip module does support short form headers. It’ll receive them, and you can enable the functionality to send them. It’s called compact headers.

1 Like

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