If you’re deploying WebRTC, you’re going to need to learn how to investigate these kind of issues yourself. In this case WebRTC requires two things to be set up before media can flow - ICE and DTLS-SRTP. ICE will find the path that can be used to exchange packets, and DTLS-SRTP for the keying material to encryption. Looking at a packet capture you need to look at these aspects to put together a timeline and determine what is at fault. If it’s ICE then you need to determine why - is it taking a long time to find candidates? Is it taking a long time to find a working path?
OK will do. I will look into ICE or DTLS-SRTP.
So what if it is not ICE who is the culprit - if it is DTLS-SRTP - what do you suggest we look into?
Also - I was browsing through the settings and I saw that I could choose either DTLS-SRTP or SRTP via in-SDP for media encryption.
I could not find much information regarding these. Do you know anything about it?
Potentially, that log does show it took 9 seconds before ICE gathering was completed. You’d need to look into the actual packet capture and put together the timeline in coordination with logs to see where it’s coming from.
As for DTLS-SRTP or SRTP via in-SDP, one is DTLS-SRTP and one is SDES-SRTP. WebRTC mandates DTLS-SRTP usage.
It seems that the delay in the STUN negotiation is related to network interfaces that have an IP address but no internet access.
According to this, the solution is to reduce the timeout. Indeed setting a timeout of say 1500 ms improves it considerably.
However, there is still this 1 to 4 second delay after the call and ICE/STUN negotiations are done.
Sometimes no delay. If I redo another call right after the first call, it is fine and there is no delay. It seems that a ‘priming’ call will help.
From what I see in Wireshark running on the client, we can clearly see that the Asterisk server starts sending audio packets, the client is receiving them, but is not handling them, until the second channel is open.
Using the Wireshark RTP player, we can see that the waveform in grey is the one sent by Asterisk. The blue one is sent by the client. We start hearing the “grey” (Asterisk) stream once the blue (Client) one is active.
The difference between “Having Delay” and “No Delay” seem to be the arrival of the “proper” DTLSv1.2 packet.
When there is no delay, this packet below seems to arrive right when Asterisk sends the first RTP packets.
When there is delay, I see a lot of these dud DTLSv1.2 packets with 1 direction RTP.
Any suggestions on why the DTLSv1.2 exchange is taking so long?
Why is Asterisk starting to send audio packets when the exchange looks like it’s not over?
We are experimenting with the “dtls_auto_generate_cert” setting you mention there and currently we cannot reproduce the problem anymore. We will run wider scale tests, but it seems this could be a step in the right direction.