Open bagusaff opened 4 weeks ago
Can you please make a more reduced example?
Can you please make a more reduced example?
Hi, really appreciate your fast response! I have updated & reduced my code example.
const handleRemoteOffer = async (offer: any) => { if (!localPC) { await setupPeerConnection(); } await localPC.setRemoteDescription(new RTCSessionDescription(offer)); const answer = await localPC.createAnswer(); await localPC.setLocalDescription(answer); socket.current?.send( JSON.stringify({type: 'answer', answer, roomId: roomIdToJoin}), ); if (remoteCandidates.length > 1) { for (let candidate of remoteCandidates) { handleRemoteICECandidate(candidate); } remoteCandidates = []; } };
Not sure if this is it, but if you end up calling setupPeerConnection
here things will break because you are attempting to set a remote offer while having a local offer.
```js const handleRemoteOffer = async (offer: any) => { if (!localPC) { await setupPeerConnection(); } await localPC.setRemoteDescription(new RTCSessionDescription(offer)); const answer = await localPC.createAnswer(); await localPC.setLocalDescription(answer); socket.current?.send( JSON.stringify({type: 'answer', answer, roomId: roomIdToJoin}), ); if (remoteCandidates.length > 1) { for (let candidate of remoteCandidates) { handleRemoteICECandidate(candidate); } remoteCandidates = []; } };
Not sure if this is it, but if you end up calling setupPeerConnection here things will break because you are attempting to set a remote offer while having a local offer.
Thanks for the insight! It was actually my most recently added code while I tried to fix the issue, which means that the issue happens even before I added that line :"))
case 'candidate':
if (!localPC || !localPC.remoteDescription?.type) {
console.log(
'Cant find peerconnection, adding candidates to queue',
);
remoteCandidates.push(data?.candidate);
} else {
handleRemoteICECandidate(data?.candidate);
}
break;
I dont know if this information is important, but If I tried to handleRemoteICE with this method it will resulted to error :
Error adding received ice candidate [Error: The remote description was null]
App Flow :
VideoCallScreen.tsx
Expected Behavior:
Call should work all the times
Observed Behavior:
Sometimes when Callee Joined the room I noticed from the Logs that the onTrack & setRemoteDescription event is not fired, resulting on video is not showing on either side. It happens like 30% of the times..
Steps to reproduce the issue:
I have provided my main logic, and my main concern is that Im not sure if the flow is correct.
Platform Information
LOGS when it's succeeded
LOGS when it failed to display video