'Call not received using PeerJS on page refresh
I am developing a video call application where when a participant reloads the page, their video will stop for every other participant and it continues once the page has loaded. For this, once a user joins a video call, they receive the peer IDs of all the other participants, and they make a call to every participant with their local video stream. The problem is that the call is being made but is not received by the other participants every time. It works sometimes upon multiple reloads for the participants. It works perfectly in localhost as well.
This is how the participants are called upon every reload:
remotePeers.forEach(remotePeer => {
if (remotePeer.id !== localPeerId) {
const call = localPeer.call(remotePeer.id, localStream);
if (call) {
call.on('stream', remoteStream => {
setRemoteStream(call.peer, remoteStream);
});
}
}
});
This is how the call is answered:
localPeer.on('call', call => {
call.answer(localStream);
call.on('stream', remoteStream => {
setRemoteStream(call.peer, remoteStream);
});
});
The peer server has been set up on a new port. There is also another WebSocket server running on a different port.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
