title: Getting pc.iceConnectionState Checking, failed in pc.oniceconnectionstatechange event in webRTC
body: <p>I'm using webrtc for video calling in react native app.<br />
  If I call to someone else and receivers receives call then I get stream of receiver but there is a problem at receiver side.<br />
  Receiver gets remotestream but it shows blank view.</p>
  <pre><code>import AsyncStorage from '@react-native-async-storage/async-storage';
      import {
        RTCIceCandidate,
        RTCPeerConnection,
        RTCSessionDescription,
      } from 'react-native-webrtc';
      import io from '../scripts/socket.io';
      const PC_CONFIG = {
        iceServers: [
          { url: 'stun:motac85002'},
        ],
      };
      export const pc = new RTCPeerConnection(PC_CONFIG);
      // Signaling methods
      export const onData = data =&gt; {
        handleSignalingData(data.data);
      };
      const ENDPOINT = 'http://52.52.75.250:3000/';
      const socket = io(ENDPOINT);
      //  const PeerConnection = () =&gt; {
      const sendData = async data =&gt; {
        const roomId = await AsyncStorage.getItem('roomId');
        const userId = parseInt(await AsyncStorage.getItem('user_id'));
        socket.emit('data', roomId, userId, data);
      };
      export const createPeerConnection = async(stream, setUsers) =&gt; {
        try {
          pc.onicecandidate = onIceCandidate;
          const userId = parseInt(await AsyncStorage.getItem('user_id'));
          pc.onaddstream = e =&gt; {
            setUsers(e.stream);
          };
          pc.addStream(stream)
         pc.oniceconnectionstatechange = function () {
        // console.log('ICE state: ', pc);
        console.log('iceConnectionState', pc.iceConnectionState);
        if (pc.iceConnectionState === &quot;failed&quot; ||
        pc.iceConnectionState === &quot;disconnected&quot; ||
        pc.iceConnectionState === &quot;closed&quot;) {
          console.log('iceConnectionState  restart', userId);
            //  console.log('ICE state: ', pc);
      // Handle the failure
      pc.restartIce();
    }
      };
          console.log('PeerConnection created',      userId);
          // sendOffer();
        } catch (error) {
          console.error('PeerConnection failed: ', error);
        }
      };
      export const callSomeone = () =&gt; {
        pc.createOffer({}).then(setAndSendLocalDescription, error =&gt; {
          console.error('Send offer failed: ', error);
        });
      };
      const setAndSendLocalDescription = sessionDescription =&gt; {
        pc.setLocalDescription(sessionDescription);
        sendData(sessionDescription);
      };
      const onIceCandidate = event =&gt; {
        if (event.candidate) {
          sendData({
            type: 'candidate',
            candidate: event.candidate,
          });
        }
      };
      export const disconnectPeer = () =&gt;{
        pc.close();
      }
      const sendAnswer = () =&gt; {
        pc.createAnswer().then(setAndSendLocalDescription, error =&gt; {
          console.error('Send answer failed: ', error);
        });
      };
      export const handleSignalingData = data =&gt; {
        switch (data.type) {
          case 'offer':
            pc.setRemoteDescription(new RTCSessionDescription(data));
            sendAnswer();
            break;
          case 'answer':
            pc.setRemoteDescription(new RTCSessionDescription(data));
            break;
          case 'candidate':
            pc.addIceCandidate(new RTCIceCandidate(data.candidate));
            break;
        }
      };
      // }
      // export default PeerConnection
  </code></pre>
  <p>Can anyone please tell me why at receiver side video stream is not displaying?<br />
  Also there is a remoteStream issue in motorola device. Why is this happening?</p>