Hi, I’m running a fresh Asterisk 16.13.0 install. The Asterisk server is behind double NAT in a local LAN. The phones are in the same LAN. I’ve multiple sip accounts and sip providers.
Problem: If I receive a call on one of my sip accounts, the audio from the external caller to the local phone is delayed by about 2s. Audio from local phone to external caller is not delayed!
I thought this is a firewall/NAT problem but looks like I was wrong. Adding an Answer()
before Dial()
the local phone fixes the problem.
; extension with 2s delay for incoming pstn-call
[sipprovider-in]
exten = _X.,1,NoOp(Provider 1)
same = n,Dial(PJSIP/201,20)
same = n,Hangup()
Here is the log for the delayed example:
– Executing [xxxxxxxxxx@sipprovider-in:2] Dial(“PJSIP/sipprovider-0000003a”, “PJSIP/201,20”) in new stack
– Called PJSIP/201
– PJSIP/201-0000003b is ringing
– PJSIP/201-0000003b is ringing
0x7fee8001b7f0 – Strict RTP learning after remote address set to: 192.168.1.14:12528
– PJSIP/201-0000003b answered PJSIP/sipprovider-0000003a
0x7fee80093680 – Strict RTP learning after remote address set to: 62.xxx.xxx.xxx:17810
As you can see, the second strict RTP
happens after the answered-line. This seems to cause the 2s delay in the audio stream from external caller to local phone.
Accidentally, I found a simple solution.
; extension without 2s delay for incoming pstn-call
[sipprovider-in]
exten = _X.,1,NoOp(Provider 1)
same = n,Answer()
same = n,Dial(PJSIP/201,20)
same = n,Hangup()
Here is the log for the non-delayed example:
– Executing [xxxxxxxxxx@sipprovider-in:3] Dial(“PJSIP/sipprovider-00000038”, “PJSIP/201,20”) in new stack
– Called PJSIP/201
– PJSIP/201-00000039 is ringing
– PJSIP/201-00000039 is ringing
0x7fee8006dec0 – Strict RTP switching to RTP target address 62.xxx.xxx.xxx:17832 as source
0x7fee8008a7d0 – Strict RTP learning after remote address set to: 192.168.1.14:12526
– PJSIP/201-00000039 answered PJSIP/sipprovider-00000038
Both strict RTP
happen before the answered-line and magically there is no delay.
Question: Any idea why this happens and what a cleaner solution might be?
Thanks in advance.