I'm following this tutorial, to make a simple example of WebRTC. But the remote video does not appear in any browser and Chrome does not show the error:
Uncaught (in promise) DOMException: Error processing ICE candidate
I made a log not setRemoteDescription method:
peerConn.setRemoteDescription(new RTCSessionDescription(signal.sdp), function(){
alert('success')
}, function(e){ console.log(e); alert(e)});
And then I get the following error:
OperationError: Failed to set remote offer sdp: Called in wrong state: STATE_SENTOFFER
In the tutorial in question, the author claims that he is able to do everything right and that the error should be on my side. Has anyone ever experienced this?
(sorry about my English)
EDIT: (Include code)
I am still a layman on the subject, the tutorial link quoted at the beginning was the cleanest I found to start having fun. I'll put the source I think it's important:
Back-end - server.js
/** successful connection */
wss.on('connection', function (client) {
console.log("A new WebSocket client was connected.");
/** incomming message */
client.on('message', function (message) {
/** broadcast message to all clients */
wss.broadcast(message, client);
});
});
// broadcasting the message to all WebSocket clients.
wss.broadcast = function (data, exclude) {
var i = 0, n = this.clients ? this.clients.length : 0, client = null;
if (n < 1) return;
console.log("Broadcasting message to all " + n + " WebSocket clients.");
for (; i < n; i++) {
client = this.clients[i];
// don't send the message to the sender...
if (client === exclude) continue;
if (client.readyState === client.OPEN) client.send(data);
else console.error('Error: the client state is ' + client.readyState);
}
};
Front-end - webrtc.js
wsc.onmessage = function (evt) {
var signal = null;
if (!peerConn) answerCall();
signal = JSON.parse(evt.data);
if (signal.sdp) {
console.log("Received SDP from remote peer.");
peerConn.setRemoteDescription(new RTCSessionDescription(signal.sdp),
function(){},
function(e){ console.log(e);
});
}
else if (signal.candidate) {
console.log("Received ICECandidate from remote peer.");
peerConn.addIceCandidate(new RTCIceCandidate(signal.candidate));
} else if ( signal.closeConnection){
console.log("Received 'close call' signal from remote peer.");
endCall();
}
};
All font: Code taken from this github repository.