Asterisk 13 with PJSIP behind NAT

Hello to all,

I’m back here to ask you for help. Premise that thanks to your previous help, I managed to create a simple application that allows me to make calls.

The problem now is that I need to install Asterisk on a server behind NAT. But the same application that used to work, does not work now. I configured the pjsip.conf with the new server parameters, but it seems still not work.

[transport-tls-nat]
type=transport
protocol=tls
bind=0.0.0.0
local_net=192.168.246.13/255.255.255.0
external_media_address=10.64.1.52
external_signaling_address=10.64.1.52
cert_file=/etc/asterisk/keys/asterisk.crt
priv_key_file=/etc/asterisk/keys/asterisk.key
method=tlsv1

[6001]
type=aor

[6001]
type=auth

[6001]
type=endpoint
transport=transport-tls-nat
disallow=all
allow=ulaw
context=from-internal
auth=6001
aors=6001
media_encryption=dtls
dtls_verify=fingerprint
dtls_cert_file=/etc/asterisk/keys/asterisk.pem
dtls_ca_file=/etc/asterisk/keys/ca.crt
dtls_setup=actpass
use_avpf=yes
ice_support=yes
direct_media=no
rtp_symmetric=yes
media_use_received_transport=yes

The following log comes from the working server:

   == WebSocket connection from '192.168.247.1:62059' for protocol 'sip' accepted using version '13'
<--- Received SIP request (697 bytes) from WSS:192.168.247.1:62059 --->
REGISTER sip:192.168.247.128 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKVUiHGdvovluSqrmNR768oCl8TgGxpOFG;rport
From: "6001"<sip:6001@192.168.247.128>;tag=fyT8bp3r05x1HkiARZme
To: "6001"<sip:6001@192.168.247.128>
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;transport=wss>;expires=200;click2call=no;+g.oma.sip-im;+audio;language="en,fr"
Call-ID: 3d8c1302-732d-51d6-ee9e-1b9816f56ade
CSeq: 16996 REGISTER
Content-Length: 0
Max-Forwards: 70
Authorization: Digest username="6001",realm="192.168.247.128",nonce="",uri="sip:192.168.247.128",response=""
User-Agent: IM-client/OMA1.0 sipML5-v1.2016.03.04
Organization: Doubango Telecom
Supported: path


<--- Transmitting SIP response (564 bytes) to WSS:192.168.247.1:62059 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62059;received=192.168.247.1;branch=z9hG4bKVUiHGdvovluSqrmNR768oCl8TgGxpOFG
Call-ID: 3d8c1302-732d-51d6-ee9e-1b9816f56ade

From: "6001" <sip:6001@192.168.247.128>;tag=fyT8bp3r05x1HkiARZme
To: "6001" <sip:6001@192.168.247.128>;tag=z9hG4bKVUiHGdvovluSqrmNR768oCl8TgGxpOFG
CSeq: 16996 REGISTER
WWW-Authenticate: Digest  realm="asterisk",nonce="1472049184/5fc8abd4217843ebc477d4e3d944e064",opaque="09c49cab1246fe46",algorithm=md5,qop="auth"
Server: Asterisk PBX 13.10.0
Content-Length:  0


<--- Received SIP request (868 bytes) from WSS:192.168.247.1:62059 --->
REGISTER sip:192.168.247.128 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKcS6QhflQadIl4bvq74x2BKU0uLOmQlqO;rport
From: "6001"<sip:6001@192.168.247.128>;tag=fyT8bp3r05x1HkiARZme
To: "6001"<sip:6001@192.168.247.128>
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;transport=wss>;expires=200;click2call=no;+g.oma.sip-im;+audio;language="en,fr"
Call-ID: 3d8c1302-732d-51d6-ee9e-1b9816f56ade


-- Added contact 'sips:6001@192.168.247.1:62059;transport=wss;rtcweb-breaker=yes' to AOR '6001' with expiration of 200 seconds
  == Contact 6001/sips:6001@192.168.247.1:62059;transport=wss;rtcweb-breaker=yes has been created
<--- Transmitting SIP response (531 bytes) to WSS:192.168.247.1:62059 --->
SIP/2.0 200 OK
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62059;received=192.168.247.1;branch=z9hG4bKcS6QhflQadIl4bvq74x2BKU0uLOmQlqO
Call-ID: 3d8c1302-732d-51d6-ee9e-1b9816f56ade

From: "6001" <sip:6001@192.168.247.128>;tag=fyT8bp3r05x1HkiARZme
To: "6001" <sip:6001@192.168.247.128>;tag=z9hG4bKcS6QhflQadIl4bvq74x2BKU0uLOmQlqO
CSeq: 16997 REGISTER
Date: Wed, 24 Aug 2016 14:33:04 GMT
Contact: <sips:6001@192.168.247.1:62059;transport=wss;rtcweb-breaker=yes>;expires=199
Server: Asterisk PBX 13.10.0
Content-Length:  0


  == Contact 6001/sips:6001@192.168.247.1:61947;transport=wss;rtcweb-breaker=yes has been deleted
-- Contact 6001/sips:6001@192.168.247.1:62059;transport=wss;rtcweb-breaker=yes is now Unknown.  RTT: 0.000 msec
<--- Received SIP request (3047 bytes) from WSS:192.168.247.1:62059 --->
INVITE sip:100@192.168.247.128 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bK4RURr52aSilpFsrD8goD1ABqBU8Afpi8;rport
From: "6001"<sip:6001@192.168.247.128>;tag=pdgbG59zuOHysAuRgi7n
To: <sip:100@192.168.247.128>
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;click2call=no;transport=wss>;impi=6001;ha1=f28e622fa9264aae340ab737cc30523a;+g.oma.sip-im;language="en"
Call-ID: 5c9ef96a-c91b-483d-fa9e-fae06f7804b7
CSeq: 10790 INVITE
Content-Type: application/sdp
Content-Length: 2425
Max-Forwards: 70
User-Agent: IM-client/OMA1.0 sipML5-v1.2016.03.04
Organization: Doubango Telecom

v=0
o=- 8555061578601882000 2 IN IP4 127.0.0.1
s=Doubango Telecom - chrome
t=0 0
a=group:BUNDLE audio
a=msid-semantic: WMS CX6gGlravcT5BbfStbp42Uz0OeIfks7RWerC
m=audio 50266 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 126
c=IN IP4 192.168.10.1
a=rtcp:50269 IN IP4 192.168.10.1
a=candidate:2430253621 1 udp 2122260223 192.168.10.1 50266 typ host generation 0 network-id 2
a=candidate:1337008544 1 udp 2122194687 192.168.247.1 50267 typ host generation 0 network-id 1
a=candidate:790668530 1 udp 2122129151 10.3.6.34 50268 typ host generation 0 network-id 3
a=candidate:2430253621 2 udp 2122260222 192.168.10.1 50269 typ host generation 0 network-id 2
a=candidate:1337008544 2 udp 2122194686 192.168.247.1 50270 typ host generation 0 network-id 1
a=candidate:790668530 2 udp 2122129150 10.3.6.34 50271 typ host generation 0 network-id 3
a=candidate:3730392773 1 tcp 1518280447 192.168.10.1 9 typ host tcptype active generation 0 network-id 2
a=candidate:20110672 1 tcp 1518214911 192.168.247.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:1638094850 1 tcp 1518149375 10.3.6.34 9 typ host tcptype active generation 0 network-id 3
a=candidate:3730392773 2 tcp 1518280446 192.168.10.1 9 typ host tcptype active generation 0 network-id 2
a=candidate:20110672 2 tcp 1518214910 192.168.247.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:1638094850 2 tcp 1518149374 10.3.6.34 9 typ host tcptype active generation 0 network-id 3
a=ice-ufrag:xeyUhi7/76tacyX8
a=ice-pwd:+eLVjJUF/KNcUKd3PEkOU3Iw
a=fingerprint:sha-256 37:9D:57:2B:BB:A5:B6:B9:BF:FB:DE:90:05:F6:79:A0:39:A1:44:E9:15:F7:C0:1B:CD:8F:1F:D1:A0:74:18:DF
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:126 telephone-event/8000
a=ssrc:3218470496 cname:wrepdBsQYHEspRP1
a=ssrc:3218470496 msid:CX6gGlravcT5BbfStbp42Uz0OeIfks7RWerC c0a7f375-5c4b-428c-8318-63ece09177be
a=ssrc:3218470496 mslabel:CX6gGlravcT5BbfStbp42Uz0OeIfks7RWerC
a=ssrc:3218470496 label:c0a7f375-5c4b-428c-8318-63ece09177be

<--- Transmitting SIP response (554 bytes) to WSS:192.168.247.1:62059 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62059;received=192.168.247.1;branch=z9hG4bK4RURr52aSilpFsrD8goD1ABqBU8Afpi8
Call-ID: 5c9ef96a-c91b-483d-fa9e-fae06f7804b7
From: "6001" <sip:6001@192.168.247.128>;tag=pdgbG59zuOHysAuRgi7n
To: <sip:100@192.168.247.128>;tag=z9hG4bK4RURr52aSilpFsrD8goD1ABqBU8Afpi8
CSeq: 10790 INVITE
WWW-Authenticate: Digest  realm="asterisk",nonce="1472049203/f6beb4788952135bb06217a07dcf6f9d",opaque="0c9e68db483948af",algorithm=md5,qop="auth"
Server: Asterisk PBX 13.10.0
Content-Length:  0


<--- Received SIP request (372 bytes) from WSS:192.168.247.1:62059 --->
ACK sip:100@192.168.247.128 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bK4RURr52aSilpFsrD8goD1ABqBU8Afpi8;rport
From: "6001"<sip:6001@192.168.247.128>;tag=pdgbG59zuOHysAuRgi7n
To: <sip:100@192.168.247.128>;tag=z9hG4bK4RURr52aSilpFsrD8goD1ABqBU8Afpi8
Call-ID: 5c9ef96a-c91b-483d-fa9e-fae06f7804b7
CSeq: 10790 ACK
Content-Length: 0
Max-Forwards: 70


<--- Received SIP request (3332 bytes) from WSS:192.168.247.1:62059 --->
INVITE sip:100@192.168.247.128 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKyMnoDxPrmzfzG7eV3rv1X1z0e8DpfdRc;rport
From: "6001"<sip:6001@192.168.247.128>;tag=pdgbG59zuOHysAuRgi7n
To: <sip:100@192.168.247.128>
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;click2call=no;transport=wss>;impi=6001;ha1=f28e622fa9264aae340ab737cc30523a;+g.oma.sip-im;language="en"
Call-ID: 5c9ef96a-c91b-483d-fa9e-fae06f7804b7
CSeq: 10791 INVITE
Content-Type: application/sdp
Content-Length: 2425
Max-Forwards: 70
Authorization: Digest username="6001",realm="asterisk",nonce="1472049203/f6beb4788952135bb06217a07dcf6f9d",uri="sip:100@192.168.247.128",response="c8df79474d31250e089a9e6c602f51b8",algorithm=md5,cnonce="ff128f3a38e44d28a4feb61d1fb64133",opaque="0c9e68db483948af",qop=auth,nc=00000001
User-Agent: IM-client/OMA1.0 sipML5-v1.2016.03.04
Organization: Doubango Telecom

v=0
o=- 8555061578601882000 2 IN IP4 127.0.0.1
s=Doubango Telecom - chrome
t=0 0
a=group:BUNDLE audio
a=msid-semantic: WMS CX6gGlravcT5BbfStbp42Uz0OeIfks7RWerC
m=audio 50266 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 126
c=IN IP4 192.168.10.1
a=rtcp:50269 IN IP4 192.168.10.1
a=candidate:2430253621 1 udp 2122260223 192.168.10.1 50266 typ host generation 0 network-id 2
a=candidate:1337008544 1 udp 2122194687 192.168.247.1 50267 typ host generation 0 network-id 1
a=candidate:790668530 1 udp 2122129151 10.3.6.34 50268 typ host generation 0 network-id 3
a=candidate:2430253621 2 udp 2122260222 192.168.10.1 50269 typ host generation 0 network-id 2
a=candidate:1337008544 2 udp 2122194686 192.168.247.1 50270 typ host generation 0 network-id 1
a=candidate:790668530 2 udp 2122129150 10.3.6.34 50271 typ host generation 0 network-id 3
a=candidate:3730392773 1 tcp 1518280447 192.168.10.1 9 typ host tcptype active generation 0 network-id 2
a=candidate:20110672 1 tcp 1518214911 192.168.247.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:1638094850 1 tcp 1518149375 10.3.6.34 9 typ host tcptype active generation 0 network-id 3
a=candidate:3730392773 2 tcp 1518280446 192.168.10.1 9 typ host tcptype active generation 0 network-id 2
a=candidate:20110672 2 tcp 1518214910 192.168.247.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:1638094850 2 tcp 1518149374 10.3.6.34 9 typ host tcptype active generation 0 network-id 3
a=ice-ufrag:xeyUhi7/76tacyX8
a=ice-pwd:+eLVjJUF/KNcUKd3PEkOU3Iw
a=fingerprint:sha-256 37:9D:57:2B:BB:A5:B6:B9:BF:FB:DE:90:05:F6:79:A0:39:A1:44:E9:15:F7:C0:1B:CD:8F:1F:D1:A0:74:18:DF
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:126 telephone-event/8000
a=ssrc:3218470496 cname:wrepdBsQYHEspRP1
a=ssrc:3218470496 msid:CX6gGlravcT5BbfStbp42Uz0OeIfks7RWerC c0a7f375-5c4b-428c-8318-63ece09177be
a=ssrc:3218470496 mslabel:CX6gGlravcT5BbfStbp42Uz0OeIfks7RWerC
a=ssrc:3218470496 label:c0a7f375-5c4b-428c-8318-63ece09177be

<--- Transmitting SIP response (357 bytes) to WSS:192.168.247.1:62059 --->
SIP/2.0 100 Trying
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62059;received=192.168.247.1;branch=z9hG4bKyMnoDxPrmzfzG7eV3rv1X1z0e8DpfdRc
Call-ID: 5c9ef96a-c91b-483d-fa9e-fae06f7804b7
From: "6001" <sip:6001@192.168.247.128>;tag=pdgbG59zuOHysAuRgi7n
To: <sip:100@192.168.247.128>
CSeq: 10791 INVITE
Server: Asterisk PBX 13.10.0
Content-Length:  0


-- Executing [100@from-internal:1] Answer("PJSIP/6001-00000000", "") in new stack
<--- Transmitting SIP response (1405 bytes) to WSS:192.168.247.1:62059 --->
SIP/2.0 200 OK
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62059;received=192.168.247.1;branch=z9hG4bKyMnoDxPrmzfzG7eV3rv1X1z0e8DpfdRc
Call-ID: 5c9ef96a-c91b-483d-fa9e-fae06f7804b7
From: "6001" <sip:6001@192.168.247.128>;tag=pdgbG59zuOHysAuRgi7n
To: <sip:100@192.168.247.128>;tag=3fe425f9-10de-4613-91a4-08794fba2e4d
CSeq: 10791 INVITE
Server: Asterisk PBX 13.10.0
Contact: <sips:192.168.247.1:62059;transport=WSS>
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, REFER, MESSAGE
Supported: 100rel, timer, replaces, norefersub
Content-Type: application/sdp
Content-Length:   767

v=0
o=- 3626525072 4 IN IP4 192.168.247.128
s=Asterisk
c=IN IP4 192.168.247.128
t=0 0
m=audio 17214 UDP/TLS/RTP/SAVPF 0 126
a=connection:new
a=setup:active
a=fingerprint:SHA-256 D7:61:94:8C:DD:B5:80:7E:65:F2:02:9C:70:20:6C:14:7A:EF:36:D6:0E:57:4A:81:47:C9:DE:C0:76:58:72:B1
a=ice-ufrag:0d9e19e47bc0556a0911660a6799c5c3
a=ice-pwd:54149f4e39d5808c4b4d93f43066ba75
a=candidate:Hc0a8f780 1 UDP 2130706431 192.168.247.128 17214 typ host
a=candidate:Hc0a87a01 1 UDP 2130706431 192.168.122.1 17214 typ host
a=candidate:Hc0a8f780 2 UDP 2130706430 192.168.247.128 17215 typ host
a=candidate:Hc0a87a01 2 UDP 2130706430 192.168.122.1 17215 typ host
a=rtpmap:0 PCMU/8000
a=rtpmap:126 telephone-event/8000
a=fmtp:126 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<--- Received SIP request (879 bytes) from WSS:192.168.247.1:62059 --->
ACK sips:192.168.247.1:62059;transport=WSS SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKTq0wWdTwwP4vaL964602;rport
From: "6001"<sip:6001@192.168.247.128>;tag=pdgbG59zuOHysAuRgi7n
To: <sip:100@192.168.247.128>;tag=3fe425f9-10de-4613-91a4-08794fba2e4d
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;click2call=no;transport=wss>;+g.oma.sip-im;language="en"
Call-ID: 5c9ef96a-c91b-483d-fa9e-fae06f7804b7
CSeq: 10791 ACK
Content-Length: 0
Max-Forwards: 70
Authorization: Digest username="6001",realm="asterisk",nonce="1472049203/f6beb4788952135bb06217a07dcf6f9d",uri="sips:192.168.247.1:62059;transport=WSS",response="0e23c927daec350324ce804fad240c6f",algorithm=md5,cnonce="ff128f3a38e44d28a4feb61d1fb64133",opaque="0c9e68db483948af",qop=auth,nc=00000002
User-Agent: IM-client/OMA1.0 sipML5-v1.2016.03.04
Organization: Doubango Telecom


-- Executing [100@from-internal:2] Wait("PJSIP/6001-00000000", "1") in new stack
-- Executing [100@from-internal:3] Playback("PJSIP/6001-00000000", "hello-world") in new stack
-- <PJSIP/6001-00000000> Playing 'hello-world.gsm' (language 'en')
Got  RTP packet from    192.168.10.1:50266 (type 00, seq 001484, ts 2008384140, len 000160)
Got  RTP packet from    192.168.10.1:50266 (type 00, seq 001485, ts 2008384300, len 000160)
Got  RTP packet from    192.168.10.1:50266 (type 00, seq 001486, ts 2008384460, len 000160)
Got  RTP packet from    192.168.10.1:50266 (type 00, seq 001487, ts 2008384620, len 000160)
Sent RTP packet to      192.168.10.1:50266 (via ICE) (type 00, seq 054335, ts 000160, len 000170)
Got  RTP packet from    192.168.10.1:50266 (type 00, seq 001534, ts 2008392140, len 000160)
Got  RTP packet from    192.168.10.1:50266 (type 00, seq 001535, ts 2008392300, len 000160)
[....]
-- Executing [100@from-internal:4] Hangup("PJSIP/6001-00000000", "") in new stack
  == Spawn extension (from-internal, 100, 4) exited non-zero on 'PJSIP/6001-00000000'

The following, however, is the server behind a NAT that does not work properly:

  == WebSocket connection from '172.18.41.10:62151' for protocol 'sip' accepted using version '13'
<--- Received SIP request (672 bytes) from WSS:172.18.41.10:62151 --->
REGISTER sip:10.64.1.52 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKTgv3PguqZatJBqeaVSzngfH8SROar7fX;rport
From: "6001"<sip:6001@10.64.1.52>;tag=xlTrCXVlKW3lIMxCIGVL
To: "6001"<sip:6001@10.64.1.52>
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;transport=wss>;expires=200;click2call=no;+g.oma.sip-im;+audio;language="en,fr"
Call-ID: 28e922cf-b439-f8f4-85f8-2a746e2aa0fb
CSeq: 48239 REGISTER
Content-Length: 0
Max-Forwards: 70
Authorization: Digest username="6001",realm="10.64.1.52",nonce="",uri="sip:10.64.1.52",response=""
User-Agent: IM-client/OMA1.0 sipML5-v1.2016.03.04
Organization: Doubango Telecom
Supported: path


<--- Transmitting SIP response (553 bytes) to WSS:172.18.41.10:62151 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62151;received=172.18.41.10;branch=z9hG4bKTgv3PguqZatJBqeaVSzngfH8SROar7fX
Call-ID: 28e922cf-b439-f8f4-85f8-2a746e2aa0fb

From: "6001" <sip:6001@10.64.1.52>;tag=xlTrCXVlKW3lIMxCIGVL
To: "6001" <sip:6001@10.64.1.52>;tag=z9hG4bKTgv3PguqZatJBqeaVSzngfH8SROar7fX
CSeq: 48239 REGISTER
WWW-Authenticate: Digest  realm="asterisk",nonce="1472049281/714d1f4f205489f8e474f01894390e1e",opaque="7d2f71ca31d5bc93",algorithm=md5,qop="auth"
Server: Asterisk PBX 13.10.0
Content-Length:  0


<--- Received SIP request (848 bytes) from WSS:172.18.41.10:62151 --->
REGISTER sip:10.64.1.52 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKeRWTG7bMWwzQb8XKDt1vmMBQgJNAoPMH;rport
From: "6001"<sip:6001@10.64.1.52>;tag=xlTrCXVlKW3lIMxCIGVL
To: "6001"<sip:6001@10.64.1.52>
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;transport=wss>;expires=200;click2call=no;+g.oma.sip-im;+audio;language="en,fr"
Call-ID: 28e922cf-b439-f8f4-85f8-2a746e2aa0fb


    -- Added contact 'sips:6001@172.18.41.10:62151;transport=wss;rtcweb-breaker=yes' to AOR '6001' with expiration of 200 seconds
  == Contact 6001/sips:6001@172.18.41.10:62151;transport=wss;rtcweb-breaker=yes has been created
<--- Transmitting SIP response (519 bytes) to WSS:172.18.41.10:62151 --->
SIP/2.0 200 OK
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62151;received=172.18.41.10;branch=z9hG4bKeRWTG7bMWwzQb8XKDt1vmMBQgJNAoPMH
Call-ID: 28e922cf-b439-f8f4-85f8-2a746e2aa0fb

From: "6001" <sip:6001@10.64.1.52>;tag=xlTrCXVlKW3lIMxCIGVL
To: "6001" <sip:6001@10.64.1.52>;tag=z9hG4bKeRWTG7bMWwzQb8XKDt1vmMBQgJNAoPMH
CSeq: 48240 REGISTER
Date: Wed, 24 Aug 2016 14:34:41 GMT
Contact: <sips:6001@172.18.41.10:62151;transport=wss;rtcweb-breaker=yes>;expires=199
Server: Asterisk PBX 13.10.0
Content-Length:  0


  == Contact 6001/sips:6001@172.18.41.10:62121;transport=wss;rtcweb-breaker=yes has been deleted
    -- Contact 6001/sips:6001@172.18.41.10:62151;transport=wss;rtcweb-breaker=yes is now Unknown.  RTT: 0.000 msec
<--- Received SIP request (3032 bytes) from WSS:172.18.41.10:62151 --->
INVITE sip:100@10.64.1.52 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bK3tfanih1tgR9Bo2RSSSfZ2D4BWXboyAx;rport
From: "6001"<sip:6001@10.64.1.52>;tag=N0EWBQhWKeyiufN25RoP
To: <sip:100@10.64.1.52>
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;click2call=no;transport=wss>;impi=6001;ha1=8e90f50e70ee87b67310a450b9247d1a;+g.oma.sip-im;language="en"
Call-ID: 090b979d-6f34-639d-4bc6-f529f71fd1d7
CSeq: 16355 INVITE
Content-Type: application/sdp
Content-Length: 2425
Max-Forwards: 70
User-Agent: IM-client/OMA1.0 sipML5-v1.2016.03.04
Organization: Doubango Telecom

v=0
o=- 5646413650390666000 2 IN IP4 127.0.0.1
s=Doubango Telecom - chrome
t=0 0
a=group:BUNDLE audio
a=msid-semantic: WMS ykQ8GE5Z5IiB6MkL2E4LXMddDfQ1rD5WiTbI
m=audio 57000 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 126
c=IN IP4 192.168.10.1
a=rtcp:57003 IN IP4 192.168.10.1
a=candidate:2430253621 1 udp 2122260223 192.168.10.1 57000 typ host generation 0 network-id 2
a=candidate:1337008544 1 udp 2122194687 192.168.247.1 57001 typ host generation 0 network-id 1
a=candidate:790668530 1 udp 2122129151 10.3.6.34 57002 typ host generation 0 network-id 3
a=candidate:2430253621 2 udp 2122260222 192.168.10.1 57003 typ host generation 0 network-id 2
a=candidate:1337008544 2 udp 2122194686 192.168.247.1 57004 typ host generation 0 network-id 1
a=candidate:790668530 2 udp 2122129150 10.3.6.34 57005 typ host generation 0 network-id 3
a=candidate:3730392773 1 tcp 1518280447 192.168.10.1 9 typ host tcptype active generation 0 network-id 2
a=candidate:20110672 1 tcp 1518214911 192.168.247.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:1638094850 1 tcp 1518149375 10.3.6.34 9 typ host tcptype active generation 0 network-id 3
a=candidate:3730392773 2 tcp 1518280446 192.168.10.1 9 typ host tcptype active generation 0 network-id 2
a=candidate:20110672 2 tcp 1518214910 192.168.247.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:1638094850 2 tcp 1518149374 10.3.6.34 9 typ host tcptype active generation 0 network-id 3
a=ice-ufrag:KKdn/yIU2QbiFR4N
a=ice-pwd:tQyLZJoxYQarv9pE7KOl/BO/
a=fingerprint:sha-256 BF:11:7B:3B:16:04:3A:02:FC:EA:62:DF:E7:C3:E5:AC:8D:26:DD:47:81:A2:D8:14:04:A0:28:DF:4B:19:3E:75
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:126 telephone-event/8000
a=ssrc:3002576694 cname:gEMCSFcPudO3/Ln3
a=ssrc:3002576694 msid:ykQ8GE5Z5IiB6MkL2E4LXMddDfQ1rD5WiTbI e5db4c2a-8d43-451b-b8ab-5f1e4e64203b
a=ssrc:3002576694 mslabel:ykQ8GE5Z5IiB6MkL2E4LXMddDfQ1rD5WiTbI
a=ssrc:3002576694 label:e5db4c2a-8d43-451b-b8ab-5f1e4e64203b

<--- Transmitting SIP response (543 bytes) to WSS:172.18.41.10:62151 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62151;received=172.18.41.10;branch=z9hG4bK3tfanih1tgR9Bo2RSSSfZ2D4BWXboyAx
Call-ID: 090b979d-6f34-639d-4bc6-f529f71fd1d7
From: "6001" <sip:6001@10.64.1.52>;tag=N0EWBQhWKeyiufN25RoP
To: <sip:100@10.64.1.52>;tag=z9hG4bK3tfanih1tgR9Bo2RSSSfZ2D4BWXboyAx
CSeq: 16355 INVITE
WWW-Authenticate: Digest  realm="asterisk",nonce="1472049294/47e70f17352cfcaa36f3568b98b9a41d",opaque="2ebd5a9e3af1ffa9",algorithm=md5,qop="auth"
Server: Asterisk PBX 13.10.0
Content-Length:  0


<--- Received SIP request (357 bytes) from WSS:172.18.41.10:62151 --->
ACK sip:100@10.64.1.52 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bK3tfanih1tgR9Bo2RSSSfZ2D4BWXboyAx;rport
From: "6001"<sip:6001@10.64.1.52>;tag=N0EWBQhWKeyiufN25RoP
To: <sip:100@10.64.1.52>;tag=z9hG4bK3tfanih1tgR9Bo2RSSSfZ2D4BWXboyAx
Call-ID: 090b979d-6f34-639d-4bc6-f529f71fd1d7
CSeq: 16355 ACK
Content-Length: 0
Max-Forwards: 70


<--- Received SIP request (3312 bytes) from WSS:172.18.41.10:62151 --->
INVITE sip:100@10.64.1.52 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKXt5EWN43Vn0KoIWrT1bIEmPHOldFsqJk;rport
From: "6001"<sip:6001@10.64.1.52>;tag=N0EWBQhWKeyiufN25RoP
To: <sip:100@10.64.1.52>
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;click2call=no;transport=wss>;impi=6001;ha1=8e90f50e70ee87b67310a450b9247d1a;+g.oma.sip-im;language="en"
Call-ID: 090b979d-6f34-639d-4bc6-f529f71fd1d7
CSeq: 16356 INVITE
Content-Type: application/sdp
Content-Length: 2425
Max-Forwards: 70
Authorization: Digest username="6001",realm="asterisk",nonce="1472049294/47e70f17352cfcaa36f3568b98b9a41d",uri="sip:100@10.64.1.52",response="e3620073f64ff18ad71b1ca48736eb05",algorithm=md5,cnonce="e4f0d0cebd9e2718cdb9a329544605d3",opaque="2ebd5a9e3af1ffa9",qop=auth,nc=00000001
User-Agent: IM-client/OMA1.0 sipML5-v1.2016.03.04
Organization: Doubango Telecom

v=0
o=- 5646413650390666000 2 IN IP4 127.0.0.1
s=Doubango Telecom - chrome
t=0 0
a=group:BUNDLE audio
a=msid-semantic: WMS ykQ8GE5Z5IiB6MkL2E4LXMddDfQ1rD5WiTbI
m=audio 57000 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 126
c=IN IP4 192.168.10.1
a=rtcp:57003 IN IP4 192.168.10.1
a=candidate:2430253621 1 udp 2122260223 192.168.10.1 57000 typ host generation 0 network-id 2
a=candidate:1337008544 1 udp 2122194687 192.168.247.1 57001 typ host generation 0 network-id 1
a=candidate:790668530 1 udp 2122129151 10.3.6.34 57002 typ host generation 0 network-id 3
a=candidate:2430253621 2 udp 2122260222 192.168.10.1 57003 typ host generation 0 network-id 2
a=candidate:1337008544 2 udp 2122194686 192.168.247.1 57004 typ host generation 0 network-id 1
a=candidate:790668530 2 udp 2122129150 10.3.6.34 57005 typ host generation 0 network-id 3
a=candidate:3730392773 1 tcp 1518280447 192.168.10.1 9 typ host tcptype active generation 0 network-id 2
a=candidate:20110672 1 tcp 1518214911 192.168.247.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:1638094850 1 tcp 1518149375 10.3.6.34 9 typ host tcptype active generation 0 network-id 3
a=candidate:3730392773 2 tcp 1518280446 192.168.10.1 9 typ host tcptype active generation 0 network-id 2
a=candidate:20110672 2 tcp 1518214910 192.168.247.1 9 typ host tcptype active generation 0 network-id 1
a=candidate:1638094850 2 tcp 1518149374 10.3.6.34 9 typ host tcptype active generation 0 network-id 3
a=ice-ufrag:KKdn/yIU2QbiFR4N
a=ice-pwd:tQyLZJoxYQarv9pE7KOl/BO/
a=fingerprint:sha-256 BF:11:7B:3B:16:04:3A:02:FC:EA:62:DF:E7:C3:E5:AC:8D:26:DD:47:81:A2:D8:14:04:A0:28:DF:4B:19:3E:75
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:126 telephone-event/8000
a=ssrc:3002576694 cname:gEMCSFcPudO3/Ln3
a=ssrc:3002576694 msid:ykQ8GE5Z5IiB6MkL2E4LXMddDfQ1rD5WiTbI e5db4c2a-8d43-451b-b8ab-5f1e4e64203b
a=ssrc:3002576694 mslabel:ykQ8GE5Z5IiB6MkL2E4LXMddDfQ1rD5WiTbI
a=ssrc:3002576694 label:e5db4c2a-8d43-451b-b8ab-5f1e4e64203b

<--- Transmitting SIP response (346 bytes) to WSS:172.18.41.10:62151 --->
SIP/2.0 100 Trying
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62151;received=172.18.41.10;branch=z9hG4bKXt5EWN43Vn0KoIWrT1bIEmPHOldFsqJk
Call-ID: 090b979d-6f34-639d-4bc6-f529f71fd1d7
From: "6001" <sip:6001@10.64.1.52>;tag=N0EWBQhWKeyiufN25RoP
To: <sip:100@10.64.1.52>
CSeq: 16356 INVITE
Server: Asterisk PBX 13.10.0
Content-Length:  0


    -- Executing [100@from-internal:1] Answer("PJSIP/6001-00000001", "") in new stack
<--- Transmitting SIP response (1245 bytes) to WSS:172.18.41.10:62151 --->
SIP/2.0 200 OK
Via: SIP/2.0/WSS df7jal23ls0d.invalid;rport=62151;received=172.18.41.10;branch=z9hG4bKXt5EWN43Vn0KoIWrT1bIEmPHOldFsqJk
Call-ID: 090b979d-6f34-639d-4bc6-f529f71fd1d7
From: "6001" <sip:6001@10.64.1.52>;tag=N0EWBQhWKeyiufN25RoP
To: <sip:100@10.64.1.52>;tag=d93ec645-c2c2-4789-9635-8c7568c5e960
CSeq: 16356 INVITE
Server: Asterisk PBX 13.10.0
Contact: <sips:10.64.1.52:62151;transport=WSS>
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, REFER, MESSAGE
Supported: 100rel, timer, replaces, norefersub
Content-Type: application/sdp
Content-Length:   621

v=0
o=- 2389953296 4 IN IP4 192.168.246.13
s=Asterisk
c=IN IP4 10.64.1.52
t=0 0
m=audio 17814 UDP/TLS/RTP/SAVPF 0 126
a=connection:new
a=setup:active
a=fingerprint:SHA-256 47:C5:16:63:AB:81:2B:EB:38:05:32:74:5C:5B:4E:88:DD:93:38:63:B0:8B:56:31:10:63:4F:90:0C:82:4A:F8
a=ice-ufrag:0a0fa0110658f118103a8ce205151d14
a=ice-pwd:0fd0a40b5f747d4779059b1e1c62394e
a=candidate:Hc0a8f60d 1 UDP 2130706431 192.168.246.13 17814 typ host
a=candidate:Hc0a8f60d 2 UDP 2130706430 192.168.246.13 17815 typ host
a=rtpmap:0 PCMU/8000
a=rtpmap:126 telephone-event/8000
a=fmtp:126 0-16
a=ptime:20


a=maxptime:150
a=sendrecv

<--- Received SIP request (863 bytes) from WSS:172.18.41.10:62151 --->
ACK sips:10.64.1.52:62151;transport=WSS SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKQitUBDCSicU1V8mgsheQ;rport
From: "6001"<sip:6001@10.64.1.52>;tag=N0EWBQhWKeyiufN25RoP
To: <sip:100@10.64.1.52>;tag=d93ec645-c2c2-4789-9635-8c7568c5e960
Contact: "6001"<sips:6001@df7jal23ls0d.invalid;rtcweb-breaker=yes;click2call=no;transport=wss>;+g.oma.sip-im;language="en"
Call-ID: 090b979d-6f34-639d-4bc6-f529f71fd1d7
CSeq: 16356 ACK
Content-Length: 0
Max-Forwards: 70
Authorization: Digest username="6001",realm="asterisk",nonce="1472049294/47e70f17352cfcaa36f3568b98b9a41d",uri="sips:10.64.1.52:62151;transport=WSS",response="eda5dc919a1df9af89f7b10578ef68e9",algorithm=md5,cnonce="e4f0d0cebd9e2718cdb9a329544605d3",opaque="2ebd5a9e3af1ffa9",qop=auth,nc=00000002
User-Agent: IM-client/OMA1.0 sipML5-v1.2016.03.04
Organization: Doubango Telecom


    -- Executing [100@from-internal:2] Wait("PJSIP/6001-00000001", "1") in new stack
    -- Executing [100@from-internal:3] Playback("PJSIP/6001-00000001", "hello-world") in new stack
Sent RTP packet to      192.168.10.1:57000 (type 00, seq 038347, ts 000160, len 000160)
    -- <PJSIP/6001-00000001> Playing 'hello-world.gsm' (language 'en')
Sent RTP packet to      192.168.10.1:57000 (type 00, seq 038348, ts 000320, len 000160)
Sent RTP packet to      192.168.10.1:57000 (type 00, seq 038349, ts 000480, len 000160)
Sent RTP packet to      192.168.10.1:57000 (type 00, seq 038350, ts 000640, len 000160)
[....]
    -- Executing [100@from-internal:4] Hangup("PJSIP/6001-00000001", "") in new stack
  == Spawn extension (from-internal, 100, 4) exited non-zero on 'PJSIP/6001-00000001'

It is clear that the following part is missing:

Got RTP packet from 192.168.10.1:****** (type 00, seq 001500, ts 2008386700, len 000160)

Can someone help me? For more information just ask. Thanks a lot to everyone!
Vincenzo

This would be happening because the ICE negotiation has failed as both sides are unable to communicate with each other. You can either turn on STUN so Asterisk can discover its external IP address (this is done in rtp.conf) or you can configure Asterisk to replace the host IP address in the ICE candidates with its external IP address (this is also done in rtp.conf). You would also need to ensure that the RTP ports are forwarded to it.

Hi jcolp, thank you.

But i have already set the rtp.conf

[general]
rtpstart=10002
rtpend=20000
rtcpinterval=9998
rtpchecksums=no
strictrtp=no
icesupport=yes
stunaddr=stun.l.google.com:19302

Is this configuration correct?

If that Google server is responding yes… but I don’t see an external address in your logs. What does the full console output with debug (added to logger.conf and core set debug 9) on say?

Hi jcolp, yes Google server respond correctly. Output console is on http://pastebin.com/6AvkUW82

Cannot paste here because is too long :disappointed_relieved:

Let me know if you need of more information.

Thanks for now!

Hrm, how about just doing “stun set debug on”?

Here: http://pastebin.com/pcUs6MAx

It really doesn’t appear to be requesting its external IP address from the STUN server. Do you see anything at startup about the STUN server address being invalid when res_rtp_asterisk is loaded?

No, the log is

Loading res_rtp_asterisk.so.
== Registered RTP engine 'asterisk'
== Parsing '/etc/asterisk/rtp.conf': Found
== RTP Allocating from port range 10002 -> 20000
== res_rtp_asterisk.so => (Asterisk RTP Stack)

What is exactly the problem? It may depend on the fact that the client is behind NAT?

ICE candidates provide the IP addresses and ports that you are reachable at. If each side has only candidates which are behind the NAT, then they can’t communicate and you get no audio. The STUN functionality allows Asterisk to discover its external IP address and add that as a candidate - increasing the chance of communicating. I’m very confused over why it is not working, but a work-around for now would be to use the “[ice_mappings]” section to replace your internal IP address in the candidates with your public external address.

Can you provide me an example of [ice_mappings] ?

There’s an example in rtp.conf:

; The format for these overrides is: ; ; <local address> => <advertised address> ; ; The following will replace 192.168.1.10 with 1.2.3.4 during ICE ; negotiation: ; ;192.168.1.10 => 1.2.3.4

Ok, but why i don’t see, in rtp debug, the fragment “With ICE” when return packet?

rtp debug shows you RTP traffic, not ICE negotiation. Until ICE is negotiated and a path determined RTP can’t be sent using ICE.

Ok, another question… My webrtc client is behind NAT. This configuration is correctly?

[6001]
type=friend
username=6001
host=dynamic
secret=6001
nat=force_rport,comedia
encryption=yes
avpf=yes
icesupport=yes
context=from-internal
directmedia=no
transport=wss
force_avp=yes
dtlsenable=yes
dtlsverify=no
dtlscertfile=/etc/asterisk/keys/asterisk.pem
dtlsprivatekey=/etc/asterisk/keys/asterisk.pem
dtlssetup=actpass

Yes, that looks perfectly fine!

Hi jcolp,

Unfortunately no good news. I tried to also set the [ice_mappings] but nothing. No audio.

Can you suggest something else?

Thank you!

That’s the only thing I can suggest without really digging in - can you provide an updated console output, as well as your Asterisk version?

Does it matter that the type=auth is blank? See https://wiki.asterisk.org/wiki/display/AST/Configuring+res_pjsip+to+work+through+NAT

[sipus_auth]
type=auth
auth_type=userpass
password=************
username=1112223333
realm=gw1.example.com

I am facing same issue. I go this error in my asterisk console

res_rtp_asterisk.c:2042 __rtp_recvfrom: DTLS failure occurred on RTP instance ‘0x7fc680038e28’ due to reason ‘sslv3 alert handshake failure’, terminating

I tried above config’s, but it fails. This error happens only in updated chrome browser. I can hear audio in firefox and old chrome version browsers.

This is the method i configured asterisk and web extension http://www.nethram.com/webrtc-with-asterisk-12/. But i am using asterisk 13.2.0 and ubuntu 14.04. I thought this issue was with openssl, so i uninstalled and installedd openssl from source, still this problem persists.