Clients connect, but there is no sound on calls

Clients connect, I make a call and other client answers, but I do not hear a sound.

Also I do not hear hello-world sound when I dial 9000 from mobile or desktop client.

My extensions.conf:

[office-phones]
exten => 1001,1,Dial(PJSIP/neo)
exten => 1002,1,Dial(PJSIP/morpheus)

exten => 9000,1,Answer()
same => n,Playback(hello-world)
same => n,Hangup()

My pjsip.conf:

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

[neo]
type=endpoint
context=office-phones
disallow=all
allow=ulaw
auth=neo-auth
aors=neo
direct_media=no

[neo-auth]
type=auth
auth_type=userpass
username=neo
password=XXXXX

[neo]
type=aor
max_contacts=10

[morpheus]
type=endpoint
context=office-phones
disallow=all
allow=ulaw
auth=morpheus-auth
aors=morpheus
direct_media=no

[morpheus-auth]
type=auth
auth_type=userpass
username=morpheus
password=XXXXX

[morpheus]
type=aor
max_contacts=10

My rtp.conf:

[general]
rtpstart=10000
rtpend=10099

When I dial 9000 some pockets are sent to the client and I see the following in Asterisk logs:

    -- Executing [9000@office-phones:1] Answer("PJSIP/neo-0000001c", "") in new stack
       > 0x7ee538039640 -- Strict RTP learning after remote address set to: 176.15.165.80:31384
    -- Executing [9000@office-phones:2] Playback("PJSIP/neo-0000001c", "hello-world") in new stack
Sent RTP packet to      176.15.165.80:31384 (type 00, seq 051027, ts 000160, len 000160)
    -- <PJSIP/neo-0000001c> Playing 'hello-world.gsm' (language 'en')
Sent RTP packet to      176.15.165.80:31384 (type 00, seq 051028, ts 000320, len 000160)
Sent RTP packet to      176.15.165.80:31384 (type 00, seq 051029, ts 000480, len 000160)
Sent RTP packet to      176.15.165.80:31384 (type 00, seq 051030, ts 000640, len 000160)
Sent RTP packet to      176.15.165.80:31384 (type 00, seq 051031, ts 000800, len 000160)
Sent RTP packet to      176.15.165.80:31384 (type 00, seq 051032, ts 000960, len 000160)
Sent RTP packet to      176.15.165.80:31384 (type 00, seq 051033, ts 001120, len 000160)
Sent RTP packet to      176.15.165.80:31384 (type 00, seq 051034, ts 001280, len 000160)
Sent RTP packet to      176.15.165.80:31384 (type 00, seq 051035, ts 001440, len 000160)

but the sound does not play. What does it mean?

See my blog post for more details on what experimentations I did.

At least it is not firewall at the client side, because I tried “ufw disable”. My mobile client is connected to the internet via 4G and desktop client is run in Windows Sandbox behind a router. Asterisk is run in a Docker container on a VPS in a data center. Asterisk version is 22.2.0.

I run Docker container with the following command:

sudo docker run -d --rm --name asterisk --cpus=0.5 -p 5060:5060/udp -p 5061:5061 -p 10000-10099:10000-10099/udp u24asterisk

I configured the transports as follows:

[t_wan](!)
type = transport
bind = 0.0.0.0:5060
domain = developernote.com
external_signaling_address = developernote.com
external_media_address = developernote.com
tos = cs3
cos = 3
 
[transport-udp](t_wan)
protocol = udp
 
[transport-tcp](t_wan)
protocol = tcp
 
[transport-tls](t_wan)
bind = 0.0.0.0:5061
cert_file = /etc/asterisk/ssl/cert.pem
priv_key_file = /etc/asterisk/ssl/priv_key.pem
protocol = tls
method=tlsv1_2

All the transports started to work, ZoiPer client worked over TLS, but Linphone client did not, because it does not support self-signed certificates.

And I was able to hear the sound ONE TIME when I made a call with number 1002 from mobile phone to my Windows Sandbox over UDP transport (Linphone clients). All the subsequent calls were silent.

Probably it depends on some random conditions.

Also I enabled GSM codec on the client side, but it did not help.

See Dockerfile here: DockerLemp/asterisk at master · dmitriano/DockerLemp · GitHub

Is there any NAT routed?Is this behind firewall?
How is your network configured?
Also there is no reply from the another endpoint.
The asterisk Is sending packets to

176.15.165.80

but there is no reply.

Add these in the endpoints

rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
ice_support = yes
direct_media = no
use_avpf = yes

rtpkeepalive = 1

This will not help. Where it comes in is when you are receiving from them, but they are not receiving from you, because the address in their SDP is wrong.

There is no indication that the other NAT setting are an issue here.

My impression is that this is normally only used for WebRTC, and WebRTC never uses UDP as a transport. Getting this wrong normally results in the session failing to establish, or BYE being sent immediately after ACK.

I think this is most likely a Docker problem. The use of Docker is discouraged for Asterisk, and I’d advise learning how to use Asterisk without it, before adding in the extra complication.

I have two clients in Sandboxes on Windows 10 machines in a local network behind a router. First client is Linphone (client A) and second client is ZoiPer (client B), so the clients A and B are behind NAT. Also I have Linphone (client C), ZipPer (client D) and PortSIP (client F) on my Android mobile phone connected to the internet over 4G (so there is no NAT). The server is in the Docker container with default network configuration with all the ports mapped to the host.

I am not an expert in the area of networking. I am familiar with the basic things like IP tables, routing, NAT, TCP, UDP, and I do not understand all these options well enough, but fortunately everything started to work when I added the following to endpoints configuration:

media_address = developernote.com
rtp_symmetric = yes
direct_media = no
rewrite_contact = yes
force_rport = yes
ice_support = yes

I hear hello-world sound from all the clients and all the clients can call each other and talk to each other, see my new blog post for details and full confiugations. Also see the logs: A call from client C (1001) to client A(1002), A call from client B (1003) to client C (1003).

So basically everything works, except one thing: when I call in the reverse direction from client A(1002) to client C (1001) the client C does not accept the call, see the log:

<--- Received SIP request (1202 bytes) from UDP:91.122.37.167:60224 --->
INVITE sip:1001@developernote.com SIP/2.0
Via: SIP/2.0/UDP 172.28.33.149:5060;branch=z9hG4bK.oToGYJ3yg;rport
From: <sip:morpheus@developernote.com>;tag=tpOU6t7m3
To: sip:1001@developernote.com
CSeq: 20 INVITE
Call-ID: ~YSoeIdCOX
Max-Forwards: 70
Supported: replaces, outbound, gruu, path, record-aware
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 539
Contact: <sip:morpheus@91.122.37.167:60224;transport=udp>;+org.linphone.specs="lime"
User-Agent: Linphone-Desktop/5.2.6 (6f734bd0-54ba-4970-a73f-452bb5e8f241) windows/10 Qt/5.15.2 LinphoneSDK/5.3.72
 
v=0
o=morpheus 1747 1089 IN IP4 172.28.33.149
s=Talk
c=IN IP4 172.28.33.149
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
a=record:off
m=audio 51886 RTP/AVP 96 97 98 0 8 18 101 99 100
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:101 telephone-event/48000
a=rtpmap:99 telephone-event/16000
a=rtpmap:100 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr
 
<--- Transmitting SIP response (468 bytes) to UDP:91.122.37.167:60224 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 172.28.33.149:5060;rport=60224;received=91.122.37.167;branch=z9hG4bK.oToGYJ3yg
Call-ID: ~YSoeIdCOX
From: <sip:morpheus@developernote.com>;tag=tpOU6t7m3
To: <sip:1001@developernote.com>;tag=z9hG4bK.oToGYJ3yg
CSeq: 20 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1739385758/30b4ee26aa7347d97a82879e410717be",opaque="54d9b6794678f7fe",algorithm=MD5,qop="auth"
Server: Asterisk PBX 22.2.0
Content-Length:  0
 
 
<--- Received SIP request (359 bytes) from UDP:91.122.37.167:60224 --->
ACK sip:1001@developernote.com SIP/2.0
Via: SIP/2.0/UDP 172.28.33.149:5060;branch=z9hG4bK.oToGYJ3yg;rport
Call-ID: ~YSoeIdCOX
From: <sip:morpheus@developernote.com>;tag=tpOU6t7m3
To: <sip:1001@developernote.com>;tag=z9hG4bK.oToGYJ3yg
Contact: <sip:morpheus@91.122.37.167:60224;transport=udp>;+org.linphone.specs="lime"
Max-Forwards: 70
CSeq: 20 ACK

Probably it is something specific to Linphone desktop client (A) that does not work behind NAT while ZoiPer desktop client (B) works.

Also when I add

use_avpf = yes

the clients can’t call each other at all and I got the following logs:

<--- Received SIP request (1211 bytes) from UDP:176.15.165.103:18674 --->
INVITE sip:1003@developernote.com SIP/2.0
Via: SIP/2.0/UDP 13.160.171.146:49167;branch=z9hG4bK.vsV6mfo5o;rport
From: <sip:neo@developernote.com>;tag=ksAWZdGPO
To: sip:1003@developernote.com
CSeq: 20 INVITE
Call-ID: rpYumD5CL~
Max-Forwards: 70
Supported: replaces, outbound, gruu, path, record-aware
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 549
Contact: <sip:neo@13.160.171.146:49167;transport=udp>;expires=3599;+org.linphone.specs="lime"
User-Agent: LinphoneAndroid/5.2.5 (A54 пользователя Dmitry) LinphoneSDK/5.3.47 (tags/5.3.47^0)

v=0
o=neo 2288 389 IN IP4 13.160.171.146
s=Talk
c=IN IP4 13.160.171.146
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
a=record:off
m=audio 40489 RTP/AVP 96 97 98 0 8 18 101 99 100
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:101 telephone-event/48000
a=rtpmap:99 telephone-event/16000
a=rtpmap:100 telephone-event/8000
a=rtcp:48215
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

<--- Transmitting SIP response (466 bytes) to UDP:176.15.165.103:18674 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 13.160.171.146:49167;rport=18674;received=176.15.165.103;branch=z9hG4bK.vsV6mfo5o
Call-ID: rpYumD5CL~
From: <sip:neo@developernote.com>;tag=ksAWZdGPO
To: <sip:1003@developernote.com>;tag=z9hG4bK.vsV6mfo5o
CSeq: 20 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1739390212/e676c2b34b1c9d09105abf0156c941a2",opaque="58a0bf35256b5484",algorithm=MD5,qop="auth"
Server: Asterisk PBX 22.2.0
Content-Length:  0


<--- Received SIP request (365 bytes) from UDP:176.15.165.103:18674 --->
ACK sip:1003@developernote.com SIP/2.0
Via: SIP/2.0/UDP 176.15.165.103:18674;branch=z9hG4bK.vsV6mfo5o;rport
Call-ID: rpYumD5CL~
From: <sip:neo@developernote.com>;tag=ksAWZdGPO
To: <sip:1003@developernote.com>;tag=z9hG4bK.vsV6mfo5o
Contact: <sip:neo@176.15.165.103:18674;transport=udp>;expires=3599;+org.linphone.specs="lime"
Max-Forwards: 70
CSeq: 20 ACK


<--- Received SIP request (1493 bytes) from UDP:176.15.165.103:18674 --->
INVITE sip:1003@developernote.com SIP/2.0
Via: SIP/2.0/UDP 13.160.171.146:49167;branch=z9hG4bK.qEvnwQs0c;rport
From: <sip:neo@developernote.com>;tag=ksAWZdGPO
To: sip:1003@developernote.com
CSeq: 21 INVITE
Call-ID: rpYumD5CL~
Max-Forwards: 70
Supported: replaces, outbound, gruu, path, record-aware
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Content-Type: application/sdp
Content-Length: 549
Contact: <sip:neo@13.160.171.146:49167;transport=udp>;expires=3599;+org.linphone.specs="lime"
User-Agent: LinphoneAndroid/5.2.5 (A54 пользователя Dmitry) LinphoneSDK/5.3.47 (tags/5.3.47^0)
Authorization:  Digest realm="asterisk", nonce="1739390212/e676c2b34b1c9d09105abf0156c941a2", algorithm=MD5, opaque="58a0bf35256b5484", username="neo",  uri="sip:1003@developernote.com", response="8ff3f0330e4cbde0ee0d8a0d18493fe1", cnonce="~4anhCiuV~2ah9jf", nc=00000001, qop=auth

v=0
o=neo 2288 389 IN IP4 13.160.171.146
s=Talk
c=IN IP4 13.160.171.146
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
a=record:off
m=audio 40489 RTP/AVP 96 97 98 0 8 18 101 99 100
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:101 telephone-event/48000
a=rtpmap:99 telephone-event/16000
a=rtpmap:100 telephone-event/8000
a=rtcp:48215
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

<--- Transmitting SIP response (292 bytes) to UDP:176.15.165.103:18674 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 13.160.171.146:49167;rport=18674;received=176.15.165.103;branch=z9hG4bK.qEvnwQs0c
Call-ID: rpYumD5CL~
From: <sip:neo@developernote.com>;tag=ksAWZdGPO
To: <sip:1003@developernote.com>
CSeq: 21 INVITE
Server: Asterisk PBX 22.2.0
Content-Length:  0


[Feb 12 19:56:52] e[1;31mERRORe[0m[34]: e[1;37mres_pjsip_session.ce[0m:e[1;37m946e[0m e[1;37mhandle_incoming_sdpe[0m:  neo: Couldn't negotiate stream 0:audio-0:audio:sendrecv (nothing)
<--- Transmitting SIP response (346 bytes) to UDP:176.15.165.103:18674 --->
SIP/2.0 488 Not Acceptable Here
Via: SIP/2.0/UDP 13.160.171.146:49167;rport=18674;received=176.15.165.103;branch=z9hG4bK.qEvnwQs0c
Call-ID: rpYumD5CL~
From: <sip:neo@developernote.com>;tag=ksAWZdGPO
To: <sip:1003@developernote.com>;tag=db96d465-c127-4fed-bbee-9fd85d86e04d
CSeq: 21 INVITE
Server: Asterisk PBX 22.2.0
Content-Length:  0


<--- Received SIP request (384 bytes) from UDP:176.15.165.103:18674 --->
ACK sip:1003@developernote.com SIP/2.0
Via: SIP/2.0/UDP 176.15.165.103:18674;branch=z9hG4bK.qEvnwQs0c;rport
Call-ID: rpYumD5CL~
From: <sip:neo@developernote.com>;tag=ksAWZdGPO
To: <sip:1003@developernote.com>;tag=db96d465-c127-4fed-bbee-9fd85d86e04d
Contact: <sip:neo@176.15.165.103:18674;transport=udp>;expires=3599;+org.linphone.specs="lime"
Max-Forwards: 70
CSeq: 21 ACK

Also, as you can see, there are the following error messages in the logs even when the calls are successful:

PJ ICE Rx error status code: 370400 'Bad Request'.

are they critical?

Think there has been a NAT problem.

The ip address is a private ip address which the sip client can’t reach

yes as david said the avpf is for webrtc phones.

please check your NAT configurations in docker

Thank you david

Probably I am missing something important about Docker. In my understanding NAT configuration is port forwarding, right?

I map the the container ports to the host when I run Docker container:

sudo docker run -d --rm --name asterisk --cpus=0.5 -p 5060:5060/udp -p 5060:5060 -p 5061:5061 -p 10000-10099:10000-10099/udp u24asterisk

and I can see that the ports are mapped with the command

sudo docker inspect asterisk

that displays mapped ports and the container IP address that is 172.17.0.3. See the full output on my blog.

Today I did another two test calls from C to A (successful) and from A to C (failed) and noticed that this IP address 172.28.33.149 appears in the logs of the both calls. Also there is IP address 13.160.171.146, for example.

IP address of client C is 176.15.165.103 and external IP address of client A is 91.122.37.167 . Server IP address is 172.236.29.157.

172.28.33.149 is the local IP address of client A in Windows Sandbox (which external IP address
is 91.122.37.167):

C:\Users\WDAGUtilityAccount>ipconfig

Windows IP Configuration


Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . : mshome.net
   Link-local IPv6 Address . . . . . : fe80::db7a:bb9e:748a:f5a9%205
   IPv4 Address. . . . . . . . . . . : 172.28.33.149
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . : 172.28.32.1

Successful call:

v=0
o=morpheus 1769 373 IN IP4 172.28.33.149
s=Talk
c=IN IP4 172.28.33.149
t=0 0
m=audio 50644 RTP/AVP 0 18 101
a=fmtp:18 annexb=yes
a=rtpmap:101 telephone-event/8000

Failed call:

v=0
o=morpheus 3598 1382 IN IP4 172.28.33.149
s=Talk
c=IN IP4 172.28.33.149
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
a=record:off
m=audio 50672 RTP/AVP 96 97 98 0 8 18 101 99 100
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:101 telephone-event/48000
a=rtpmap:99 telephone-event/16000
a=rtpmap:100 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

What is the difference?

The call from C to A is successful, but there is the following in the logs:

v=0
o=neo 3913 315 IN IP4 13.160.171.146
s=Talk
c=IN IP4 13.160.171.146
t=0 0

where 13.160.171.146 is the address rmnet0 interface on Android phone so, probably, it is a normal behavior when we see some local address in the logs.

You published on docker side ports 10000 - 10099.
In SDP media ports are 506xx.
Have you changed rtp.conf according to ports 10000 - 10099???

Yes, my rtp.conf:

[general]
rtpstart=10000
rtpend=10099

see the full configuration here.

In the Sandbox A I installed ZoiPer desktop client and was able to make a successful call from A to C and there was the following in the log (follow the link to see the full log):

v=0
o=Z 0 394726340 IN IP4 91.122.37.167
s=Z
c=IN IP4 91.122.37.167
t=0 0
m=audio 60267 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
a=rtcp-mux

where 91.122.37.167 is the external IP address of client A. With Linphone desktop client there was the following in the logs:

v=0
o=morpheus 3598 1382 IN IP4 172.28.33.149
s=Talk
c=IN IP4 172.28.33.149
t=0 0
a=rtcp-xr:rcvr-rtt=all:10000 stat-summary=loss,dup,jitt,TTL voip-metrics
a=record:off
m=audio 50672 RTP/AVP 96 97 98 0 8 18 101 99 100
a=rtpmap:96 opus/48000/2
a=fmtp:96 useinbandfec=1
a=rtpmap:97 speex/16000
a=fmtp:97 vbr=on
a=rtpmap:98 speex/8000
a=fmtp:98 vbr=on
a=fmtp:18 annexb=yes
a=rtpmap:101 telephone-event/48000
a=rtpmap:99 telephone-event/16000
a=rtpmap:100 telephone-event/8000
a=rtcp-fb:* trr-int 1000
a=rtcp-fb:* ccm tmmbr

where 172.28.33.149 is the local address of client A and the call fails.