2

Using SipJs 0.17.1 and freeswitch 1.10.5. Debian 10. stun:stun.l.google.com:19302 <param name="apply-candidate-acl" value="wan.auto"/>

If users using any home or office internet and when receive a call, audio appears in ~ 0.2 seconds.

9bd6fc2d-fe49-4a05-8a43-b400e4ce3565 2021-01-16 21:39:29.103910 [NOTICE] switch_rtp.c:4952 Activating RTP audio ICE: UpI7:gafAlEO8WSw1T9B3 109.201.xxx.xxx:9646
9bd6fc2d-fe49-4a05-8a43-b400e4ce3565 2021-01-16 21:39:29.103910 [INFO] switch_core_media.c:8896 Skipping RTCP ICE (Same as RTP)
9bd6fc2d-fe49-4a05-8a43-b400e4ce3565 2021-01-16 21:39:29.103910 [INFO] switch_rtp.c:3764 Activate RTP/RTCP audio DTLS client
9bd6fc2d-fe49-4a05-8a43-b400e4ce3565 2021-01-16 21:39:29.103910 [INFO] switch_rtp.c:3927 Changing audio DTLS state from OFF to HANDSHAKE
9bd6fc2d-fe49-4a05-8a43-b400e4ce3565 2021-01-16 21:39:29.243916 [INFO] switch_rtp.c:3282 Changing audio DTLS state from HANDSHAKE to SETUP
9bd6fc2d-fe49-4a05-8a43-b400e4ce3565 2021-01-16 21:39:29.263910 [INFO] switch_rtp.c:3189 audio Fingerprint Verified.
9bd6fc2d-fe49-4a05-8a43-b400e4ce3565 2021-01-16 21:39:29.263910 [INFO] switch_rtp.c:4254 Activating audio Secure RTP SEND
9bd6fc2d-fe49-4a05-8a43-b400e4ce3565 2021-01-16 21:39:29.263910 [INFO] switch_rtp.c:4232 Activating audio Secure RTP RECV
9bd6fc2d-fe49-4a05-8a43-b400e4ce3565 2021-01-16 21:39:29.263910 [INFO] switch_rtp.c:3231 Changing audio DTLS state from SETUP to READY

But when users using mobile internet and when receive a call, audio appears in ~ 1.5 seconds (subjectively longer).

7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:40.003922 [NOTICE] switch_rtp.c:4952 Activating RTP audio ICE: rzCc:NJN0su78A6fbnv6q 89.42.xxx.xxx:45466
7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:40.003922 [INFO] switch_core_media.c:8896 Skipping RTCP ICE (Same as RTP)
7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:40.003922 [INFO] switch_rtp.c:3764 Activate RTP/RTCP audio DTLS client
7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:40.003922 [INFO] switch_rtp.c:3927 Changing audio DTLS state from OFF to HANDSHAKE
7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:41.243907 [NOTICE] switch_rtp.c:1301 Auto Changing audio stun/rtp/dtls port from 89.42.xxx.xxx:45466 to 89.42.xxx.xxx:63930 idx:1
7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:41.403925 [INFO] switch_rtp.c:3282 Changing audio DTLS state from HANDSHAKE to SETUP
7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:41.423918 [INFO] switch_rtp.c:3189 audio Fingerprint Verified.
7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:41.423918 [INFO] switch_rtp.c:4254 Activating audio Secure RTP SEND
7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:41.423918 [INFO] switch_rtp.c:4232 Activating audio Secure RTP RECV
7518c5c2-a045-4535-9630-97a20c4cd980 2021-01-16 23:37:41.423918 [INFO] switch_rtp.c:3231 Changing audio DTLS state from SETUP to READY

Why does the line appear Auto Changing audio stun/rtp/dtls ? What makes ports change? How to avoid time-consuming port switching?

  • hey, we are facing the same problem, have you found a solution? – somaba Jul 05 '21 at 12:33
  • Hey. First add `` in Freeswitch profile that use to connect users. Its solve problem. Then install on server STUN service and setup it on client `const userAgentOption = { sessionDescriptionHandlerFactoryOptions: { peerConnectionConfiguration: { iceServers: [{ urls: "stun:" + operatorNS.stunUrl }] } } };`. It gives a gain of 100-500 ms – a.ts.altair Jul 07 '21 at 03:37

1 Answers1

0

Connection establishment in WebRTC uses a protocol called ICE (https://www.rfc-editor.org/rfc/rfc8445). ICE first tries to establish a direct connection between the peers, and only after this fails falls back to using a TURN relay.

In your case, it is highly likely that the direct connection is successful from your office network, but that the mobile client requires the use of a TURN server, which only happens after a timeout. If you know that a TURN server will be required, you may avoid the timeout by specifying {iceTransportPolicy: 'relay'} when you establish the peer connection.

Community
  • 1
  • 1
jch
  • 5,382
  • 22
  • 41