Asterisk/FreePBX caught by the CODECs
Having just installed and migrated a client from an old Asterisk/FreePBX system running on CentOS 5 at Rackspace to a nice new installation on Ubuntu 16.04 at Amazon Lightsail and having deleted the old system as the testing all came out clean, 24 hours running passed and then strange reports of calls that just go dead after connecting. Most calls ran through OK but some particular called numbers rang (just once) were connected but then no audio at all.
Looking through the Asterisk logs didn't show anything to write home about. The FreePBX script ran through ok, started the SIP call via a SIP Trunk Provider, all the correct responses came back, the RTP audio stream was established but the client could not hear any audio on the call. After a while the call clears down. Nothing odd showing at all in the log.
Checked all the Firewall rules to see if anything might be getting in the way of the RTP audio stream but all the rules looked fine. Then it was time to look deeper and run a packet trace. This needed to capture the SIP and RTP conversations to a capture file to download and analyse via Wireshark. "tcpdump udp portrange 1024-65535 -vvvv -s 0 -w dump.pcap" to capture the traffic.
Loaded up the capture file in Wireshark and again every thing looked ok. The SIP handshaking to INVITE the call all showed OK, the RTP handshake and stream all looks OK. The great VOIP analysis tools in Wireshark allowed me to unpick the RTP audio stream and play it ok. In this particular case an announcement to say the offices were closed.
The announcement got me thinking "was the end point another VOIP system?". It turned out that the numbers that had been reported to me as having this problem were VOIP so I started to look at the CODECs involved. The SIP Trunk was setup, as it had been in the old Asterisk/FreePBX, to use ulaw and alaw CODECs. I noticed from the packet capture that the RTP stream had decided to use alaw (G 711 A). So, initially just as a test, I changed the SIP Provider Trunk to use ulaw (G 711 U) only. Tested some calls, all working ok now.
FreePBX 188.8.131.52 Asterisk 13.1.0 with a SIP Trunk Provider making SIP/RTP connections to another VOIP system with an alaw (G 711 A) CODEC fails to decode the audio, change the Trunk to use a ulaw (G 711 U) CODEC, all is well.