Closed xicilion closed 5 months ago
Do you use node-datachannel's polyfill? The issue is that the createOffer()
/setLocalDescription()
process is completely faked in the polyfill.
If I'm not mistaken, under the hood the polyfill relies on createDataChannel()
to start the connection process (disableAutoNegotiation
is false so it calls setLocalDescription()
internally), which triggers onLocalDescription()
and populates localOffer
, which is returned by createOffer()
.
Then, the call to setLocalDescription()
actually does nothing because the description was already set on createDataChannel()
so you can't set it again. I wonder why the call is even here because it is useless and could be replaced by a noop.
The way the polyfill currently works effectively prevents you from calling setLocalDescription()
on libdatachannel.
Yes, you are right. The behavior of createOffer here is implemented based on the node-datachannel's polyfill. But it seems that we can't get the correct localDescription without creating a socket.
made a little change, just called the iceTransport->setIceAttributes
before checking the type
, and it seems to work after testing. But I'm not sure if there will be any side effects like this.
made a little change, just called the
iceTransport->setIceAttributes
before checking thetype
, and it seems to work after testing. But I'm not sure if there will be any side effects like this.
You can't do that, it introduces a side effect when it fails and the description ends-up half applied. The polyfill needs to be fixed.
In the following code snippet:
When
setLocalDescription
internally callsPeerConnection::setLocalDescription
and passes the Init parameter, it's because of the presence of the following code(https://github.com/paullouisageneau/libdatachannel/blob/master/src/peerconnection.cpp#L101):The method
iceTransport->setIceAttributes
will not be called.