I'm trying to make a simple connection, but run into the error which is the title of this post.
My code for the caller and answerer are below:
STUN Server
const servers = {iceServers: [{urls: ['stun:stun1.l.google.com:19302']}]}
Peer A (Caller)
let peer = new RTCPeerConnection(servers)
let chnl = peer.createDataChannel("channel")
chnl.onopen = e => console.log("Connection opened")
chnl.onmessage = e => console.log("New message: " + e.data)
peer.onicecandidate = e => console.log(JSON.stringify(e.candidate))
peer.createOffer().then(offer => peer.setLocalDescription(offer)).then(a => console.log(peer.localDescription))
Peer B (Answerer)
let peer = new RTCPeerConnection(servers)
peer.ondatachannel= e => {
peer.chnl = e.channel
peer.chnl.onopen = e => console.log("Connection opened")
peer.chnl.onmessage = e => console.log("New message: " + e.data)
}
peer.onicecandidate = e => console.log(JSON.stringify(e.candidate))
peer.setRemoteDescription(offer)
peer.createAnswer().then(answer=> peer.setLocalDescription(answer)).then(a => console.log(peer.localDescription))
I was running this code in 2 separate tabs of Firefox's console. I would copy the offer and answer logged from the onicecandidate callback and set these as the answerer's and caller's remote descriptions, respectively. At this moment, I would receive the error: WebRTC: ICE failed, add a TURN server and see about:webrtc for more details. I'm unsure how to resolve this.
Thank you