Strange RTP Issue with chan_sip

External calls, going through our VOIP gateway, experience inconsistent audio. Internal calls work perfectly.
This only happens with chan_sip devices. This does NOT happen with PJSIP devices using the same route/trunk/VOIP gateway.

The call connects fine in either direction (dialing, or being dialed).
Audio to our chan_sip devices works perfectly.
But Outgoing audio from the chan_sip devices only half works; the sound goes through, but its choppy and cuts in and out.

Then, after 30 seconds, the call drops and this error shows in the Asterisk logs:

[2017-05-05 13:14:12] NOTICE[2716] chan_sip.c: Disconnecting call ‘SIP/8064-000000a0’ for lack of RTP activity in 31 seconds
[2017-05-05 13:14:12] NOTICE[2716] chan_sip.c: Disconnecting call ‘SIP/AsteriskGW1-000000a1’ for lack of RTP activity in 31 seconds

So it looks like it’s hitting the RTP timeout and disconnecting my call.

RTP Timeout: 30
RTP Keep Alive: 1
NAT: never
RTP Port Ranges: 10000 - 20000

Obviously I have a misconfiguration somewhere. Can anyone help me figure out where to go next?

Any chance your router is “helping” you with SIP-ALG (or similar)?

Can you do a packet capture on your router to see if RTP packets are blocked or not forwarded correctly?

I did a network capture and trace in the meantime, and a few tests, trying to track down the issue. The RTP streams show up normal from the network side, and even show up in the CLI and asterisk log with “rtp set debug on” with the correct IPs and ports within the default RTP 10k-20k range.

I’m using asterisk v13.12.1, but I recalled I did not have this problem on a different system I built recently, v13.2, so I also built a dev box to experiment.

Prod box is Asterisk 13.12.1
My test box is Asterisk 13.2.0

I have the SIP and extension configs set identically, using the same model phones, and am using the same VOIP device.

Asterisk 13.12.1 still experiences the issue, RTP times out. The ast logs show the RTP just fine.

However, Asterisk 13.2 works perfectly and does not drop or timeout. The ast logs show the RTP just fine, same as v13.12.1.

Huh. Extremely weird, but a change in behavior at least gives me something to work with.

Know how I said the audio was choppy in my initial post? While tracing and comparing the RTP streams of both boxes, I realized that’s actually because of the “RTP Keep Alive: 1”. It’s not seeing the RTP stream, so the keep alive kicks in, and tries to insert it’s own “comfort noise” which disrupts the actual RTP. I disabled the keep alive, and now the audio is crystal clear.

It does still drop the call when it hits the “RTP Timeout: 30” so it’s obviously still not properly seeing the RTP. My workaround for now is setting the timeout to an unreasonably high number, while I search for a true cause and resolution.
Any further advice or input is welcome!

In other words, you see RTP streams both ways when doing rtp debug from the Asterisk CLI, but the call nevertheless always hangs up after 30 seconds due to rtp timeout?