react-native-webrtc: Black screen problem when calling via specific operator

I can’t receive calls on a specific mobile operator

To summarize my problem as follows, I am testing it on TestFligt with two different operators on two iOS devices. Vodafone operator can call anyone, but no one can call that line. The same problem occurs when I plug the operator into the other phone. But there is no problem with other operators. I tried many things but couldn’t find a solution. I am sharing an example from my code below.

const newPeerConn = new RTCPeerConnection({
    iceServers: [
        {
            urls: ['stun:stun1.l.google.com:19302'],
        },
        {
            urls: 'turn:xxxx:3478',
            username: 'xxxxx',  // Kullanıcı adı
            credential: 'xxxxx'  // Şifre
        }
    ]
});
const getLocalStreamAsync = async () => {
    const sourceInfos: any = await mediaDevices.enumerateDevices();
    let videoSourceId;
    for (let i = 0; i < sourceInfos.length; i++) {
        const sourceInfo = sourceInfos[i];
        console.log(sourceInfo);
        if (sourceInfo.kind == 'videoinput' && sourceInfo.facing == 'front') {
            videoSourceId = sourceInfo.deviceId;
        }
    }
    console.log('videoSourceId', videoSourceId)
    const stream = await mediaDevices
        .getUserMedia({
            audio: true,
            video: {
                mandatory: {
                    minWidth: 500,
                    minHeight: 300,
                    minFrameRate: 30,
                },
                facingMode: 'user',
                optional: videoSourceId ? [{ sourceId: videoSourceId }] : [],
            },
        });
    return stream;
}
export const processCallAsync = createAsyncThunk(
    "call-screen/processCallAsync",
    async ({ otherUserData, peerConnection, member }: { otherUserData: any, peerConnection: RTCPeerConnection, member: any }) => {
        const localStream = await getLocalStreamAsync();
        localStream.getTracks().forEach(track => peerConnection.addTrack(track, localStream));
        const sessionDescription = await peerConnection?.createOffer({});
        await peerConnection?.setLocalDescription(sessionDescription);
        return { peerConnection, sessionDescription, member, localStream, otherUserData };
    }
);
      processCallAsync.fulfilled,
                (state, action: PayloadAction<any>) => {
                    state.peerConnection = action.payload.peerConnection;
                    state.localStream = action.payload.localStream;
                    state.otherUserId = action.payload.otherUserData.id;
                    state.otherUserData = action.payload.otherUserData;
                    state.type = CallTypeEnum.OUTGOING_CALL;
                    const newUUId = uuid.v4().toString();
                    state.uuid = newUUId;
                    socket.emit('call', {
                        calleeId: action.payload.otherUserData.id?.toString(),
                        rtcMessage: action.payload.sessionDescription,
                        user: action.payload.member,
                        uuid: newUUId
                    });
                    RNCallKeep.startCall(newUUId, action.payload.otherUserData?.nickname, action.payload.otherUserData?.nickname, 'generic', true);
                }
       socket.on('ICEcandidate', data => {
            let message = data.rtcMessage;
            if (peerConnection) {
                dispatch(addIceCandidate(message));
            }
        });

        peerConnection.addEventListener('track', event => {
            if (event?.track) {
                dispatch(setRemoteStream(event.track));
            }
        });


        peerConnection.addEventListener('icecandidate', event => {
            if (event?.candidate) {
                socket.emit('ICEcandidate', {
                    calleeId: otherUserId,
                    rtcMessage: {
                        label: event.candidate.sdpMLineIndex,
                        id: event.candidate.sdpMid,
                        candidate: event.candidate.candidate,
                    },
                });
            } else {
                console.log(event)
                console.log('End of candidates.', callerId, otherUserId);
            }
        });

        peerConnection.addEventListener("iceconnectionstatechange", (event) => {
            console.log('iceconnectionstatechange', event, peerConnection.iceConnectionState);
            if (["checking", "closed"].includes(peerConnection.iceConnectionState)) {
                peerConnection.restartIce();
            }
        });

        peerConnection.addEventListener("icegatheringstatechange", (event) => {
            console.log('onicegatheringstatechange', peerConnection.iceGatheringState);
        });

Platform Information

  • React Native Version: 0.71.7
  • WebRTC Module Version: 118.0.7
  • Platform OS + Version: iOS 17.4.1

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Finally I found the problem. The problem was caused by some operators sending ice candidates with a delay. It is working smoothly now. Thank you for your support.