Asteris within the Docker doesn't properly sent RTP packets

Hi,

I am running asterisk in docker exposing ports:
- ‘5060:5060’
- ‘5060:5060/udp’
- ‘8088:8088’
- ‘10000-10100:10000-10100/udp’
Also I am running test-call react app which doing SIP endpoint registration in asterisk it works fine.

The docker is running in a server on 209.38.226.105 public external ip. When I doing the test MOH call to asterisk I didn’t hear the result. But when I switch asterisk network_mode to "host" in docker-compose.yml everything is works. But I don’t want to manage it that way.

Down bellow is my config:
pjsip.conf

[transport-ws]
type=transport
protocol=ws
bind=0.0.0.0
local_net=172.18.0.0/16
local_net=172.17.0.0/16
local_net=192.168.0.0/24
local_net=192.168.1.0/24
local_net=192.168.10.0/24
local_net=10.135.0.0/16
external_media_address=209.38.226.105
external_signaling_address=209.38.226.105

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
local_net=172.18.0.0/16
local_net=172.17.0.0/16
local_net=192.168.0.0/24
local_net=192.168.1.0/24
local_net=192.168.10.0/24
local_net=10.135.0.0/16
external_media_address=209.38.226.105
external_signaling_address=209.38.226.105

; Define template for AOR
[aor-template](!)
type=aor
max_contacts=1
remove_existing=yes

; Define template for Authentication
[auth-template](!)
type=auth
auth_type=userpass

; Define template for Endpoint
[endpoint-template](!)
type=endpoint
dtls_auto_generate_cert=yes
webrtc=yes
transport=transport-ws  ; Can be overridden if needed
context=from-extensions
disallow=all
allow=ulaw
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
direct_media=no

;Endpoint 7001
[7001](aor-template)
[7001](auth-template)
username=7001
password=7001
[7001](endpoint-template)
aors=7001
auth=7001

rtp.conf

[general]
rtpstart=10000
rtpend=10100
externip=209.38.226.10
5strictrtp=no

http.conf

[general]
enabled=yes
bindaddr=0.0.0.0

Logs MOH call:

<--- Received SIP request (2035 bytes) from WS:172.18.0.1:33350 --->
INVITE sip:*65@127.0.0.1 SIP/2.0
Via: SIP/2.0/WS 8ffe8ja0fneu.invalid;branch=z9hG4bK940322
Max-Forwards: 69
To: <sip:*65@127.0.0.1>
From: <sip:7001@209.38.226.105>;tag=miogbvaut5
Call-ID: lh5fclbsdkhjvpudcq2l
CSeq: 7911 INVITE
Contact: <sip:0u6lgt88@8ffe8ja0fneu.invalid;transport=ws;ob>
Content-Type: application/sdp
Session-Expires: 90
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: timer,ice,replaces,outbound
User-Agent: JsSIP 3.10.1
Content-Length: 1526

v=0
o=- 3218542325569698403 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=extmap-allow-mixed
a=msid-semantic: WMS f2c12c3e-5ba2-4b56-b946-72c866fb5a70
m=audio 55617 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126
c=IN IP4 192.168.0.106
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:2362100473 1 udp 2122260223 192.168.0.106 55617 typ host generation 0 network-id 1 network-cost 10
a=candidate:1918901869 1 tcp 1518280447 192.168.0.106 9 typ host tcptype active generation 0 network-id 1 network-cost 10
a=ice-ufrag:biz/
a=ice-pwd:0yUmh9jr1l3eSyoSU8F81yGH
a=ice-options:trickle
a=fingerprint:sha-256 94:F6:B5:42:A9:BE:11:27:E1:D7:7D:F5:A5:04:4C:AE:27:DB:76:4B:CB:8A:F8:CC:B3:36:75:18:DA:22:D8:25
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=sendrecv
a=msid:f2c12c3e-5ba2-4b56-b946-72c866fb5a70 062e2aa8-7d5d-4c30-b349-7e60a85c5726
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:63 red/48000/2
a=fmtp:63 111/111
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:126 telephone-event/8000
a=ssrc:1315512538 cname:4pHE3K6PFVqjG6ns
a=ssrc:1315512538 msid:f2c12c3e-5ba2-4b56-b946-72c866fb5a70 062e2aa8-7d5d-4c30-b349-7e60a85c5726

<--- Transmitting SIP response (455 bytes) to WS:172.18.0.1:33350 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WS 8ffe8ja0fneu.invalid;rport=33350;received=172.18.0.1;branch=z9hG4bK940322
Call-ID: lh5fclbsdkhjvpudcq2l
From: <sip:7001@209.38.226.105>;tag=miogbvaut5
To: <sip:*65@127.0.0.1>;tag=z9hG4bK940322
CSeq: 7911 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1716383401/6e90a716d6651b584ce7874e66e51769",opaque="2cd99b8244f891a3",algorithm=MD5,qop="auth"
Server: Asterisk PBX 21.3.1
Content-Length:  0


<--- Received SIP request (385 bytes) from WS:172.18.0.1:33350 --->
ACK sip:*65@127.0.0.1 SIP/2.0
Via: SIP/2.0/WS 8ffe8ja0fneu.invalid;branch=z9hG4bK940322
Max-Forwards: 69
To: <sip:*65@127.0.0.1>;tag=z9hG4bK940322
From: <sip:7001@209.38.226.105>;tag=miogbvaut5
Call-ID: lh5fclbsdkhjvpudcq2l
CSeq: 7911 ACK
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: outbound
User-Agent: JsSIP 3.10.1
Content-Length: 0


<--- Received SIP request (2304 bytes) from WS:172.18.0.1:33350 --->
INVITE sip:*65@127.0.0.1 SIP/2.0
Via: SIP/2.0/WS 8ffe8ja0fneu.invalid;branch=z9hG4bK1199364
Max-Forwards: 69
To: <sip:*65@127.0.0.1>
From: <sip:7001@209.38.226.105>;tag=miogbvaut5
Call-ID: lh5fclbsdkhjvpudcq2l
CSeq: 7912 INVITE
Authorization: Digest algorithm=MD5, username="7001", realm="asterisk", nonce="1716383401/6e90a716d6651b584ce7874e66e51769", uri="sip:*65@127.0.0.1", response="01a9e010126664d6601c60cddf4650f8", opaque="2cd99b8244f891a3", qop=auth, cnonce="74oapgqhvi2b", nc=00000001
Contact: <sip:0u6lgt88@8ffe8ja0fneu.invalid;transport=ws;ob>
Content-Type: application/sdp
Session-Expires: 90
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: timer,ice,replaces,outbound
User-Agent: JsSIP 3.10.1
Content-Length: 1526

v=0
o=- 3218542325569698403 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=extmap-allow-mixed
a=msid-semantic: WMS f2c12c3e-5ba2-4b56-b946-72c866fb5a70
m=audio 55617 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126
c=IN IP4 192.168.0.106
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:2362100473 1 udp 2122260223 192.168.0.106 55617 typ host generation 0 network-id 1 network-cost 10
a=candidate:1918901869 1 tcp 1518280447 192.168.0.106 9 typ host tcptype active generation 0 network-id 1 network-cost 10
a=ice-ufrag:biz/
a=ice-pwd:0yUmh9jr1l3eSyoSU8F81yGH
a=ice-options:trickle
a=fingerprint:sha-256 94:F6:B5:42:A9:BE:11:27:E1:D7:7D:F5:A5:04:4C:AE:27:DB:76:4B:CB:8A:F8:CC:B3:36:75:18:DA:22:D8:25
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=sendrecv
a=msid:f2c12c3e-5ba2-4b56-b946-72c866fb5a70 062e2aa8-7d5d-4c30-b349-7e60a85c5726
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:63 red/48000/2
a=fmtp:63 111/111
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:126 telephone-event/8000
a=ssrc:1315512538 cname:4pHE3K6PFVqjG6ns
a=ssrc:1315512538 msid:f2c12c3e-5ba2-4b56-b946-72c866fb5a70 062e2aa8-7d5d-4c30-b349-7e60a85c5726

<--- Transmitting SIP response (286 bytes) to WS:172.18.0.1:33350 --->
SIP/2.0 100 Trying
Via: SIP/2.0/WS 8ffe8ja0fneu.invalid;rport=33350;received=172.18.0.1;branch=z9hG4bK1199364
Call-ID: lh5fclbsdkhjvpudcq2l
From: <sip:7001@209.38.226.105>;tag=miogbvaut5
To: <sip:*65@127.0.0.1>
CSeq: 7912 INVITE
Server: Asterisk PBX 21.3.1
Content-Length:  0


    -- Executing [*65@from-extensions:1] Gosub("PJSIP/7001-00000001", "moh,s,1") in new stack
    -- Executing [s@moh:1] NoOp("PJSIP/7001-00000001", "Music On Hold") in new stack
    -- Executing [s@moh:2] Ringing("PJSIP/7001-00000001", "") in new stack
    -- Executing [s@moh:3] Wait("PJSIP/7001-00000001", "2") in new stack
<--- Transmitting SIP response (490 bytes) to WS:172.18.0.1:33350 --->
SIP/2.0 180 Ringing
Via: SIP/2.0/WS 8ffe8ja0fneu.invalid;rport=33350;received=172.18.0.1;branch=z9hG4bK1199364
Call-ID: lh5fclbsdkhjvpudcq2l
From: <sip:7001@209.38.226.105>;tag=miogbvaut5
To: <sip:*65@127.0.0.1>;tag=f9b98147-d8ed-473a-8bec-3d4322ef14cf
CSeq: 7912 INVITE
Server: Asterisk PBX 21.3.1
Contact: <sip:172.18.0.2:8088;transport=ws>
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, INFO, MESSAGE, REFER
Content-Length:  0


    -- Executing [s@moh:4] Answer("PJSIP/7001-00000001", "") in new stack
<--- Transmitting SIP response (1401 bytes) to WS:172.18.0.1:33350 --->
SIP/2.0 200 OK
Via: SIP/2.0/WS 8ffe8ja0fneu.invalid;rport=33350;received=172.18.0.1;branch=z9hG4bK1199364
Call-ID: lh5fclbsdkhjvpudcq2l
From: <sip:7001@209.38.226.105>;tag=miogbvaut5
To: <sip:*65@127.0.0.1>;tag=f9b98147-d8ed-473a-8bec-3d4322ef14cf
CSeq: 7912 INVITE
Server: Asterisk PBX 21.3.1
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, INFO, MESSAGE, REFER
Contact: <sip:172.18.0.2:8088;transport=ws>
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 90;refresher=uac
Require: timer
Content-Type: application/sdp
Content-Length:   783

v=0
o=- 3218542325569698403 4 IN IP4 172.18.0.2
s=Asterisk
c=IN IP4 172.18.0.2
t=0 0
a=msid-semantic:WMS *
a=group:BUNDLE 0
m=audio 10056 UDP/TLS/RTP/SAVPF 0 126
a=connection:new
a=setup:active
a=fingerprint:SHA-256 63:0B:86:FE:51:93:D9:C8:98:24:07:64:54:7A:F8:AF:C7:13:A4:D9:B2:2C:95:E0:A2:9B:EC:47:75:19:60:96
a=ice-ufrag:7cab21a831775a68318539f01996e112
a=ice-pwd:7884711d1351990c7abc8d62650e1cbb
a=candidate:Hac120002 1 UDP 2130706431 172.18.0.2 10056 typ host
a=rtpmap:0 PCMU/8000
a=rtpmap:126 telephone-event/8000
a=fmtp:126 0-16
a=ptime:20
a=maxptime:140
a=sendrecv
a=rtcp-mux
a=ssrc:987175789 cname:8965f0bf-aacb-4b63-970f-f9d445b773b6
a=msid:313b97c9-bd5b-444d-8bea-a1e62110177e 8b2f3d08-f550-4072-a3eb-05f66ccdcc70
a=rtcp-fb:* transport-cc
a=mid:0

<--- Received SIP request (424 bytes) from WS:172.18.0.1:33350 --->
ACK sip:172.18.0.2:8088;transport=ws SIP/2.0
Via: SIP/2.0/WS 8ffe8ja0fneu.invalid;branch=z9hG4bK4186049
Max-Forwards: 69
To: <sip:*65@127.0.0.1>;tag=f9b98147-d8ed-473a-8bec-3d4322ef14cf
From: <sip:7001@209.38.226.105>;tag=miogbvaut5
Call-ID: lh5fclbsdkhjvpudcq2l
CSeq: 7912 ACK
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: outbound
User-Agent: JsSIP 3.10.1
Content-Length: 0


    -- Executing [s@moh:5] Wait("PJSIP/7001-00000001", "1") in new stack
    -- Executing [s@moh:6] MusicOnHold("PJSIP/7001-00000001", "") in new stack
    -- Started music on hold, class 'default', on channel 'PJSIP/7001-00000001'
Sent RTP packet to      192.168.0.106:55617 (type 00, seq 021105, ts 000160, len 000160)
Sent RTP packet to      192.168.0.106:55617 (type 00, seq 021106, ts 000320, len 000160)
Sent RTP packet to      192.168.0.106:55617 (type 00, seq 021107, ts 000480, len 000160)
Sent RTP packet to      192.168.0.106:55617 (type 00, seq 021108, ts 000640, len 000160)
Sent RTP packet to      192.168.0.106:55617 (type 00, seq 021109, ts 000800, len 000160)
Sent RTP packet to      192.168.0.106:55617 (type 00, seq 021110, ts 000960, len 000160)
Sent RTP packet to      192.168.0.106:55617 (type 00, seq 021111, ts 001120, len 000160)

I guess that RTP packets should be sent to 172.18.0.1 to properly mapping by docker but I am not sure how to achieve it. Also I noticed that my RTP from client also doesn’t see in RTP logs provided by me. I read that if I use direct_media=no I can avoid using the STUN and ICE stuff…

Any idea how should I resolve that issue?

If any more details is needed please let me know.

Thanks in advance.

You’re using WebRTC. That requires ICE and DTLS-SRTP. You can’t get away from that. The media path is negotiated using ICE and candidates. If you’re behind a NAT, which you are in that environment, then rtp.conf has to be configured with ICE candidate mapping[1] or STUN has to be used to discover it - though using STUN then results in a reliance on an external STUN server.

I should also add this is effectively one of the most complex setups involving tons of different specs and technology.

[1] asterisk/configs/samples/rtp.conf.sample at master · asterisk/asterisk · GitHub

1 Like

Thanks for answer additional configuration of rtp.conf is solved my problem.

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