No audio/video due to wrong IP in SDPs

Hello everyone,

I have a linux machine with a public IP, and I need to run a docker container with Asterisk so that clients an connect and establish SIP call with and without WebRTC.

In order to avoid port problems the docker container exposes the following ports: 5060-5061 TCP and UDP for SIP, 8088-8089 TCP for WebRTC, and the ports 10000-10099 UDP and TCP for RTP.
The asterisk installation uses a realtime database to fetch the users from a MySQL, and it has the following configuration. I have manually created two extensions to devices test and test2, which are Android phones on the LAN running linphone in order to test the system.
I have the following asterisk config files

http.conf

[general]
enabled=yes
enablestatic=no
bindaddr=::
bindport=8088
prefix=
sessionlimit=100
session_inactivity=30000
session_keep_alive=15000
tlsenable=yes
tlsdisablev1=yes
tlsdisablev11=no
tlsdisablev12=no
tlsbindaddr=[::]:8089
tlscertfile=/etc/ssl/certs/cert.pem
tlsprivatekey=/etc/ssl/private/cert.key

pjsip.conf

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
local_net=172.18.0.0/24
local_net=127.0.0.1/32
external_media_address=51.67.81.254
external_signaling_address=51.67.81.254
external_signaling_port=5060

[transport-tcp]
type=transport
protocol=tcp
bind=0.0.0.0
local_net=172.18.0.0/24
local_net=127.0.0.1/32
external_media_address=51.67.81.254
external_signaling_address=51.67.81.254
external_signaling_port=5060

[transport-ws]
type=transport
protocol=ws
bind=0.0.0.0

rtp.conf

rtpstart=10000
rtpend=10099

; Whether to enable or disable ICE support. This option is disabled by default.
icesupport=true

When trying to call from one phone to the other one, the call is received and it can be established, however, no audio/video is transmited. It’s also strange that the phone receiving the call displays the direction as sip:test@172.18.0.2, which is the IP of Asterisk inside docker. It looks as if it was ignoring the transport configuration.
The logs are:

    -- Executing [test2@default:1] Dial("PJSIP/test-00000000", "PJSIP/test2,20") in new stack
    -- Called PJSIP/test2
    -- PJSIP/test2-00000001 is ringing
       > 0x7fb86c02acb0 -- Strict RTP learning after remote address set to: 192.168.1.33:35295
       > 0x7fb86c05d8a0 -- Strict RTP learning after remote address set to: 192.168.1.33:59673
    -- PJSIP/test2-00000001 answered PJSIP/test-00000000
       > 0x7fb86c018130 -- Strict RTP learning after remote address set to: 192.168.1.39:45562
       > 0x7fb86c01bfa0 -- Strict RTP learning after remote address set to: 192.168.1.39:37662
    -- Channel PJSIP/test2-00000001 joined 'simple_bridge' basic-bridge <4ff9838f-b371-46ff-89a4-243696c5cfc1>
    -- Channel PJSIP/test-00000000 joined 'simple_bridge' basic-bridge <4ff9838f-b371-46ff-89a4-243696c5cfc1>
       > 0x7fb86c01bfa0 -- Strict RTP qualifying stream type: video
       > 0x7fb86c01bfa0 -- Strict RTP switching source address to 88.12.194.19:37662
       > 0x7fb86c01bfa0 -- Strict RTP learning complete - Locking on source address 88.12.194.19:37662

I have also tried specifying the same STUN server in Asterisk, and both SIP Phones, but it still doesn’t work. Asterisk only show the following information:

And, when enabling pjsip logs I get the logs attached in logs_stun.txt , where I can see how the internal IP is being used in the SDPs.
logs_stun.txt (17.4 KB)

Do somebody know how could I fix this? I’ve been trying for some days, but I can’t manage to find a solution.
Thanks a lot in advance

If you want the ICE candidates to be different, then there are options in rtp.conf[1]

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

Thanks for your reply!
After taking a look at the github file I found out that I was missing the [general] category in the rtp.conf file. One I added it the SDP included the public IP address of my machine too, as a result of being able to use the stun server I guess.
However, I’m still unable to transmit video/audio between the devices.
I have also tried using the ice_host_candidates configuration you mentioned, and although it works in the SDP, the SIP directions still include Asterisk’s local IP address. You can find the logs attached in case it can help to debug my problem.
logs.txt (24.3 KB)

I’m also getting lots of warnings WARNING[1450][C-00000001]: res_rtp_asterisk.c:3347 __rtp_recvfrom: PJ ICE Rx error status code: 370400 'Bad Request'. which might be the cause of media problems, but I couldnt’ found any solutions.

Do you have any idea of what could be causing this problem?

Thanks a lot.

Nothing further really, except to say I’ve noticed a trend lately of linphone or linphone SDK users on this forum encountering problems and which if I recall correctly end up being configuration things on the linphone side.

Okay, I’ll try with another client then and update the post in case it works.
One more question: in this situation when Asterisk is running with a public IP and its SIP/RTP ports exposed, would it be necessary to use a TURN in any case? Or would asterisk work as a TURN server itself proxying the media when needed?

Generally not needed. Asterisk will proxy media as needed assuming direct_media is disabled in PJSIP. (Other things will also force proxying)

I’ve been trying other android apps like Zoiper, and even though I’m not getting any errors or warnings, I can’t manage to get the audio/video flowing between both phones.
The call is started from test to test2. Taking a look at the SDPs I can see that the SDP answer is:

v=0
o=- 0 1744687 IN IP4 172.18.0.2
s=Asterisk
c=IN IP4 88.12.194.19
t=0 0
m=audio 50374 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:140
a=sendrecv

Which includes Astrisk’s internal IP instead of it’s external IP or the IP of test2. Is this normal? How could I fix the problem?
I really need to fix this and I can’t find a solution.
The complete logs are:
logs.txt (26.8 KB)

The origin line is not used for media. It has no effect on that.

Ok, so no idea of why it could be failing?
I have also tried enabling RTP logs with core set debug category rtp but there are no logs, even when the call is established, could this be related to the problem?

If no RTP is being received, then nothing would produce logging.

Have you simplified your testing at all? Such as having a call just Answer and Playback?

Yes. If I define the following extension

[default]
exten = 100,1,Answer()
same = n,Wait(1)
same = n,Playback(hello-world)
same = n,Hangup()

and make a call from test2 to the extension 100, I can clearly hear the hello world audio and the call is finished. However, there are not RTP logs either, even after running the command core set debug category rtp. The logs are:

<--- Received SIP request (958 bytes) from TCP:88.12.194.19:42011 --->
INVITE sip:100@51.68.84.252:5060;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 192.168.1.36:34143;branch=z9hG4bK-524287-1---d17f74584de95105;rport
Max-Forwards: 70
Contact: <sip:test2@88.12.194.19:42011;transport=TCP>
To: <sip:100@51.68.84.252:5060>
From: <sip:test2@51.68.84.252:5060;transport=TCP>;tag=e30a736b
Call-ID: _Rl2aFA3UcJPQZrCyfXwXA..
CSeq: 1 INVITE
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Content-Type: application/sdp
Supported: replaces, norefersub, extended-refer, timer, sec-agree, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.20.2
Allow-Events: presence, kpml, talk, as-feature-event
Content-Length: 270

v=0
o=Zoiper 0 35883164 IN IP4 88.12.194.19
s=Zoiper
c=IN IP4 88.12.194.19
t=0 0
m=audio 37649 RTP/AVP 0 101 8 3
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
a=rtcp-mux
m=video 34554 RTP/AVP 116
a=rtpmap:116 VP8/90000
a=sendrecv
a=rtcp-mux

<--- Transmitting SIP response (501 bytes) to TCP:88.12.194.19:42011 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/TCP 192.168.1.36:34143;rport=42011;received=88.12.194.19;branch=z9hG4bK-524287-1---d17f74584de95105
Call-ID: _Rl2aFA3UcJPQZrCyfXwXA..
From: <sip:test2@51.68.84.252>;tag=e30a736b
To: <sip:100@51.68.84.252>;tag=z9hG4bK-524287-1---d17f74584de95105
CSeq: 1 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1708530072/471319404994dafcc2905e5b8179f85b",opaque="79535540422dc4aa",algorithm=MD5,qop="auth"
Server: Asterisk PBX 20.6.0
Content-Length:  0


<--- Received SIP request (358 bytes) from TCP:88.12.194.19:42011 --->
ACK sip:100@51.68.84.252:5060;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 192.168.1.36:34143;branch=z9hG4bK-524287-1---d17f74584de95105;rport
Max-Forwards: 70
To: <sip:100@51.68.84.252>;tag=z9hG4bK-524287-1---d17f74584de95105
From: <sip:test2@51.68.84.252:5060;transport=TCP>;tag=e30a736b
Call-ID: _Rl2aFA3UcJPQZrCyfXwXA..
CSeq: 1 ACK
Content-Length: 0


<--- Received SIP request (1260 bytes) from TCP:88.12.194.19:42011 --->
INVITE sip:100@51.68.84.252:5060;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 192.168.1.36:34143;branch=z9hG4bK-524287-1---ce3e1cf2abdc0b6c;rport
Max-Forwards: 70
Contact: <sip:test2@88.12.194.19:42011;transport=TCP>
To: <sip:100@51.68.84.252:5060>
From: <sip:test2@51.68.84.252:5060;transport=TCP>;tag=e30a736b
Call-ID: _Rl2aFA3UcJPQZrCyfXwXA..
CSeq: 2 INVITE
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Content-Type: application/sdp
Supported: replaces, norefersub, extended-refer, timer, sec-agree, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.20.2
Authorization: Digest username="test2",realm="asterisk",nonce="1708530072/471319404994dafcc2905e5b8179f85b",uri="sip:100@51.68.84.252:5060;transport=TCP",response="f24f787276496a57b4178b823be5d26d",cnonce="58b73107b64408ca8e1caa5e1f0bca0f",nc=00000001,qop=auth,algorithm=MD5,opaque="79535540422dc4aa"
Allow-Events: presence, kpml, talk, as-feature-event
Content-Length: 270

v=0
o=Zoiper 0 35883164 IN IP4 88.12.194.19
s=Zoiper
c=IN IP4 88.12.194.19
t=0 0
m=audio 37649 RTP/AVP 0 101 8 3
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
a=rtcp-mux
m=video 34554 RTP/AVP 116
a=rtpmap:116 VP8/90000
a=sendrecv
a=rtcp-mux

<--- Transmitting SIP response (309 bytes) to TCP:88.12.194.19:42011 --->
SIP/2.0 100 Trying
Via: SIP/2.0/TCP 192.168.1.36:34143;rport=42011;received=88.12.194.19;branch=z9hG4bK-524287-1---ce3e1cf2abdc0b6c
Call-ID: _Rl2aFA3UcJPQZrCyfXwXA..
From: <sip:test2@51.68.84.252>;tag=e30a736b
To: <sip:100@51.68.84.252>
CSeq: 2 INVITE
Server: Asterisk PBX 20.6.0
Content-Length:  0


    -- Executing [100@default:1] Answer("PJSIP/test2-00000001", "") in new stack
       > 0x7fb2e804ca50 -- Strict RTP learning after remote address set to: 88.12.194.19:37649
       > 0x7fb2e8039b30 -- Strict RTP learning after remote address set to: 88.12.194.19:34554
<--- Transmitting SIP response (906 bytes) to TCP:88.12.194.19:42011 --->
SIP/2.0 200 OK
Via: SIP/2.0/TCP 192.168.1.36:34143;rport=42011;received=88.12.194.19;branch=z9hG4bK-524287-1---ce3e1cf2abdc0b6c
Call-ID: _Rl2aFA3UcJPQZrCyfXwXA..
From: <sip:test2@51.68.84.252>;tag=e30a736b
To: <sip:100@51.68.84.252>;tag=d14b2c71-fc54-4e66-99e4-f4f7c5a03303
CSeq: 2 INVITE
Server: Asterisk PBX 20.6.0
Contact: <sip:51.68.84.252:5060;transport=TCP>
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, INFO, REFER, MESSAGE
Supported: 100rel, timer, replaces, norefersub
Content-Type: application/sdp
Content-Length:   313

v=0
o=- 0 35883166 IN IP4 51.68.84.252
s=Asterisk
c=IN IP4 51.68.84.252
t=0 0
m=audio 10078 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:140
a=sendrecv
m=video 10094 RTP/AVP 116
a=rtpmap:116 VP8/90000
a=sendrecv

       > 0x7fb2e8039b30 -- Strict RTP switching to RTP target address 88.12.194.19:34554 as source
<--- Received SIP request (422 bytes) from TCP:88.12.194.19:42011 --->
ACK sip:51.68.84.252:5060;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 192.168.1.36:34143;branch=z9hG4bK-524287-1---cda6dea7f583b54b;rport
Max-Forwards: 70
Contact: <sip:test2@88.12.194.19:42011;transport=TCP>
To: <sip:100@51.68.84.252>;tag=d14b2c71-fc54-4e66-99e4-f4f7c5a03303
From: <sip:test2@51.68.84.252>;tag=e30a736b
Call-ID: _Rl2aFA3UcJPQZrCyfXwXA..
CSeq: 2 ACK
User-Agent: Zoiper v2.10.20.2
Content-Length: 0


       > 0x7fb2e804ca50 -- Strict RTP switching to RTP target address 88.12.194.19:37649 as source
    -- Executing [100@default:2] Wait("PJSIP/test2-00000001", "1") in new stack
    -- Executing [100@default:3] Playback("PJSIP/test2-00000001", "hello-world") in new stack
    -- <PJSIP/test2-00000001> Playing 'hello-world.slin' (language 'en')
    -- Executing [100@default:4] Hangup("PJSIP/test2-00000001", "") in new stack
  == Spawn extension (default, 100, 4) exited non-zero on 'PJSIP/test2-00000001'
<--- Transmitting SIP request (420 bytes) to TCP:88.12.194.19:42011 --->
BYE sip:test2@88.12.194.19:42011;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 51.68.84.252:5060;rport;branch=z9hG4bKPj602a3ec9-91fa-484e-9a6e-0f4073575517;alias
From: <sip:100@51.68.84.252>;tag=d14b2c71-fc54-4e66-99e4-f4f7c5a03303
To: <sip:test2@51.68.84.252>;tag=e30a736b
Call-ID: _Rl2aFA3UcJPQZrCyfXwXA..
CSeq: 15149 BYE
Reason: Q.850;cause=16
Max-Forwards: 70
User-Agent: Asterisk PBX 20.6.0
Content-Length:  0


<--- Received SIP response (395 bytes) from TCP:88.12.194.19:42011 --->
SIP/2.0 200 OK
Via: SIP/2.0/TCP 51.68.84.252:5060;rport=5060;branch=z9hG4bKPj602a3ec9-91fa-484e-9a6e-0f4073575517;alias
Contact: <sip:test2@88.12.194.19:42011;transport=TCP>
To: <sip:test2@51.68.84.252>;tag=e30a736b
From: <sip:100@51.68.84.252>;tag=d14b2c71-fc54-4e66-99e4-f4f7c5a03303
Call-ID: _Rl2aFA3UcJPQZrCyfXwXA..
CSeq: 15149 BYE
User-Agent: Zoiper v2.10.20.2
Content-Length: 0

It would be in “rtp set debug on”. I note you haven’t provided any endpoint configuration. The following may help:

direct_media=no
rtp_symmetric=yes

I’m using realtime database to get the endpoints, so I had no enpoint.conf file, that’s why I didn’t post anything about that.
However, after setting the database entries of direct_media and rtp_symmectric, everything seems to be working perfectly.
Thanks a lot!

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