No audio on file playback from server EC2 instance

I’ve configured and set up my first implementation of Asterisk , using a free tier on AWS EC2, I have 2 handsets registered and after lots of figuring issues out can make calls between them , however in the ‘hello-world’ extension which plays back a file from the server I have no audio.

the server shows the file playingback correctly and the connection etc, however theres some issu in the handsets responding to SIP instruction after the calls are connected, is this to do with the internal IP of the EC2 instance ? or perhaps im missing something completely ? the 2 handsets work dialing each other, however hangup isnt being recieved

files are as follows, it appears the RTP packets are getting stopped

from handset
Sent to udp:172.31.29.187:5060 at 18/4/2019 12:59:41:058 (531 bytes):

BYE sip:200@172.31.29.187:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.1:39671;branch=z9hG4bK-lbdml4zya75f;rport
From: “Asterisx SIP” sip:WB001@54.245.34.51;tag=71xvqpky5f
To: sip:200@54.245.34.51;user=phone;tag=as315f8e9c
Call-ID: a266b85caf82-eg0zoa6e770l
CSeq: 3 BYE
Max-Forwards: 70
Contact: sip:WB001@192.168.1.1:39671;reg-id=1
User-Agent: snom720/8.7.3.15
RTP-RxStat: Total_Rx_Pkts=0,Rx-Pkts=0,Rx_Pkts_Lost=0,Remote_Rx_Pkts_Lost=0
RTP-TxStat: Total_Tx_Pkts=361,Tx_Pkts=361,Remote_Tx_Pkts=361
Content-Length: 0

Sent to udp:172.31.29.187:5060 at 18/4/2019 12:59:43:061 (531 bytes):

BYE sip:200@172.31.29.187:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.1:39671;branch=z9hG4bK-lbdml4zya75f;rport
From: “Asterisx SIP” sip:WB001@54.245.34.51;tag=71xvqpky5f
To: sip:200@54.245.34.51;user=phone;tag=as315f8e9c
Call-ID: a266b85caf82-eg0zoa6e770l
CSeq: 3 BYE
Max-Forwards: 70
Contact: sip:WB001@192.168.1.1:39671;reg-id=1
User-Agent: snom720/8.7.3.15
RTP-RxStat: Total_Rx_Pkts=0,Rx-Pkts=0,Rx_Pkts_Lost=0,Remote_Rx_Pkts_Lost=0
RTP-TxStat: Total_Tx_Pkts=361,Tx_Pkts=361,Remote_Tx_Pkts=361
Content-Length: 0

Received from udp:54.245.34.51:5060 at 18/4/2019 12:59:43:602 (861 bytes):

SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.1:39671;branch=z9hG4bK-d6nnkloiohf4;received=51.7.246.201;rport=39671
From: “Asterisx SIP” sip:WB001@54.245.34.51;tag=71xvqpky5f
To: sip:200@54.245.34.51;user=phone;tag=as315f8e9c
Call-ID: a266b85caf82-eg0zoa6e770l
CSeq: 2 INVITE
Server: Asterisk PBX 16.3.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Session-Expires: 1800;refresher=uas
Contact: sip:200@172.31.29.187:5060
Content-Type: application/sdp
Require: timer
Content-Length: 284

v=0
o=root 84321072 84321072 IN IP4 172.31.29.187
s=Asterisk PBX 16.3.0
c=IN IP4 172.31.29.187
t=0 0
m=audio 18306 RTP/AVP 3 0 8 101
a=rtpmap:3 GSM/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

Sent to udp:172.31.29.187:5060 at 18/4/2019 12:59:43:602 (363 bytes):

ACK sip:200@172.31.29.187:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.1:39671;branch=z9hG4bK-vwg2dfn2b0lx;rport
From: “Asterisx SIP” sip:WB001@54.245.34.51;tag=71xvqpky5f
To: sip:200@54.245.34.51;user=phone;tag=as315f8e9c
Call-ID: a266b85caf82-eg0zoa6e770l
CSeq: 2 ACK
Max-Forwards: 70
Contact: sip:WB001@192.168.1.1:39671;reg-id=1
Content-Length: 0

on the server

== Using SIP RTP CoS mark 5
> 0x7ffb8800fac0 – Strict RTP learning after remote address set to: 192.168.1.1:62190
– Executing [200@LocalSets:1] Answer(“SIP/WB001-00000007”, “”) in new stack
– Executing [200@LocalSets:2] Playback(“SIP/WB001-00000007”, “hello-world”) in new stack
– <SIP/WB001-00000007> Playing ‘hello-world.gsm’ (language ‘en’)
– Executing [200@LocalSets:3] Hangup(“SIP/WB001-00000007”, “”) in new stack
== Spawn extension (LocalSets, 200, 3) exited non-zero on ‘SIP/WB001-00000007’
[Apr 18 13:00:04] WARNING[3735]: chan_sip.c:4119 retrans_pkt: Retransmission timeout reached on transmission a266b85caf82-eg0zoa6e770l for seqno 2 (Critical Response) – See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 32000ms with no response

Ive tried setting the firewalls to off on both server and router but same issue prevails, any thoughts on where to look or what to check ?

You have to configure sip.conf as if you are behind a NAT, as you are. Without this it places the internal IP address in the SIP signaling and things will quickly fall apart.

Would I be better using pjsip ? or is this not an issue ?

is there somewhere I can read up on configuring sip_chan for behind a NAT ?

this is my sip.conf

[general]
context=default
allowguest=no
;srvlookup=no
port=5060
udpbindaddr=0.0.0.0
tcpenable=no

transport=udp ; Set the default transports. The order determines the primary default transport.
; If tcpenable=no and the transport set is tcp, we will fallback to UDP.
srvlookup=yes

office-phone
type=friend
context=LocalSets

host=dynamic
nat=force_rport,comedia

dtmfmode=auto

disallow=all
allow=ilbc
;allow=g729
allow=gsm
allow=g723
allow=ulaw
allow=alaw

;define devices with above tempalate
WB001

You will experience the same thing with either channel driver. For chan_sip there is an entire section in the sample sip.conf about NAT[1].

[1] https://github.com/asterisk/asterisk/blob/master/configs/samples/sip.conf.sample#L869

Thank you,

Im thinking I just need to set the localnet and leave nat=force_rport,comedia

so adding the below ?

localnet=192.168.0.0/255.255.0.0 ; RFC 1918 addresses
localnet = privatIP from ECS instance
localnet = public IP from EC2 instance

or is there just one localnet allowed ?

You can have multiple localnet, but you aren’t using it properly. The localnet option specifies what is local - that is: to what addresses chan_sip should not place the external IP address into the SIP/SDP. It must be used in combination with an external option, such as externip, so chan_sip knows what the external IP address to place into the SIP/SDP is.

I should also add that starting out with VoIP/Asterisk on AWS can be complicated due to the network characteristics that AWS has. You have to get everything right (letting traffic through, ensuring it is directed to the Asterisk instance and setting up chan_sip) for it to work.

Thank you so much for the guidance,

This has resolved the issue, adding

localnet=EC2 internal ip
externip=EC2 public IP

I can now hear the recording and make calls

much appreciated, I will take onboard that AWS is a cumbersome horrible akward place to do anything :slight_smile: and consider a move to a static server once tested asterisk out, we moved to it after finding massive limitations with twilio twiml and am just learning. Thanks for your time and insight.

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