title: Android WebRTC application could not establish connection between peers
body: <p>A WebRTC application was developed with STUN servers alone. These servers work well when the devices are connected to the home network and peer connection is established between devices without any issues. And while testing the application with different ISP providers, peer connection could not be established between devices.</p>
  <pre><code>private List&lt;PeerConnection.IceServer&gt; getIceServers () {
          if (Objects.equals ( null, iceServers ) || iceServers.size () == 0) {
              iceServers = new ArrayList&lt;&gt; ();
              iceServers.add ( PeerConnection.IceServer.builder ( STUN_SERVER_1 ).createIceServer () );
              iceServers.add ( PeerConnection.IceServer.builder ( STUN_SERVER_2 ).createIceServer () );
          }
          return iceServers;
      }
  </code></pre>
  <p>To solve this issue, a TURN server (using coturn) was created in Ubuntu AWS Instance. After creation, this TURN server was tested with the help of WebRTC's Trickle ICE page. While clicking 'Gather candidates', the page returns 'Done' as a final result. So, got to know that the TURN server is running successfully.</p>
  <p><a href="https://i.stack.imgur.com/9d4r7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9d4r7.png" alt="Trickle ICE page result" /></a></p>
  <p>Now, along with the existing STUN servers, this working TURN server credentials are added to the WebRTC application. So the application now has 3 ICE servers (2 Google STUN servers &amp; 1 TURN server)</p>
  <pre><code>private List&lt;PeerConnection.IceServer&gt; getIceServers () {
          if (Objects.equals ( null, iceServers ) || iceServers.size () == 0) {
              iceServers = new ArrayList&lt;&gt; ();
              iceServers.add ( PeerConnection.IceServer.builder ( STUN_SERVER_1 ).createIceServer () );
              iceServers.add ( PeerConnection.IceServer.builder ( STUN_SERVER_2 ).createIceServer () );
              iceServers.add ( PeerConnection.IceServer.builder ( TURN_SERVER_1 )
                .setUsername ( &quot;TURN_USER_NAME&quot; ).setPassword ( &quot;TURN_PASSWORD&quot; ).createIceServer () );
          }
          return iceServers;
      }
  </code></pre>
  <p>Here the problem is, even after adding the TURN server, peer connection is not established between devices on some networks. Could not sort out what makes the <strong>iceConnectionState</strong> as <strong>FAILED</strong>. If anyone has provided a solution already, please help me find that. Thanks</p>