I am building a webrtc system and currently trying to have the session description sent back to the local connection. Below is the code block I am using to have the session description reinserted on the local side, but I am getting the error below. The "lc.setRemoteDescription()" line works when I manually type the description into lc.setRemoteDescription() in the devtool console. Any ideas what this could be due to?
Javascript code
...
console.log("broadcastlist");
broadcastlist.push(data.message);
console.log(data.message);
connectcounter ++;
console.log(connectcounter)
var user = data.user
var csrftoken = $("[name=csrfmiddlewaretoken]").val();
lc.setRemoteDescription(data.message)
...
Output on browser dev tools console. ("lc.setRemoteDescription(data.message)" corresponds to the error displayed in the picture below.
That error happens when you attempt to pass a string to setRemoteDescription:
const pc = new RTCPeerConnection();
pc.setRemoteDescription("")
Assuming that your data.message is a JSON-serialized object you need to convert it to an object with JSON.parse
first.