Is the Nx Cloud up? Visit our Status Page for the current health and performance of the Nx Cloud.

Status Page

webRTC - Peerconnection failure over mobile data (4G/5G) on Android

Answered

Comments

1 comment

  • Ichiro
    • Network Optix team

    Hi Didier Boelens,

    Thanks for your questions and your understanding is correct - TURN is not always required.  However, with celluar network comparing to WIFI, there are a few significant differences.

     

    1. The NAT Type.
    The NAT type for cellular network usually CGNAT, it will sometimes cause for STUN, which results in ICE candidate listed failed.

    2.TURN Server
    Although it is not necessary always, however, in webRTC, this may cause potential issue which p2p connection failed cause the webRTC failed.

    3.Firewall/blocklist.
    This is a possible reason, but I don't think this will apply in your case.

     

    So, if possible, if your environment is usually sitting in cellular network, likely a TURN server will be quite helpful. Ex: 

    final Map<String, dynamic> configuration = {
      "iceServers": [
        // Public STUN servers from Google
        {'urls': 'stun:stun.l.google.com:19302'},
        {'urls': 'stun:stun1.l.google.com:19302'},
        {'urls': 'stun:stun2.l.google.com:19302'},
    
        // TURN server (commercial or self-hosted, with auth)
        {
          'urls': 'turn:turn.example.com:3478', // sample TURN
          'username': 'yourUsername',
          'credential': 'yourPassword'
        }
      ],
      'sdpSemantics': 'unified-plan',
      // Optional: fallback to TURN only if P2P fails (good for mobile data)
      'iceTransportPolicy': 'all', // or 'relay' for TURN
    };

    and likely you may also consider candidate fallback to TURN for cellular network only,, i.e. 'iceTransportPolicy': 'relay'

     

    Sometime, IPv6 may also affect the connection, you may extend your configuration with IPv6 supported to workaround this case. 

    So far, I assume the case you have is exact as your assumption about the TURN server. Although it is not necessary, but for cellular network  in different regions, the cases might be slightly different .

     

    Hope this helps. Thanks for your understanding.

    0

Please sign in to leave a comment.