paullouisageneau / libjuice

JUICE is a UDP Interactive Connectivity Establishment library
Mozilla Public License 2.0
403 stars 75 forks source link

`agent_set_local_ice_attributes` will be refused to be called #255

Closed xicilion closed 1 month ago

xicilion commented 1 month ago

In the following code snippet:

const offerSdp = await peerConnection.createOffer();
const mungedOfferSdp = munge(offerSdp, ufrag);
await peerConnection.setLocalDescription(mungedOfferSdp);

When agent_set_local_ice_attributes is called, because (https://github.com/paullouisageneau/libjuice/blob/master/src/agent.c#L573):

if (agent->conn_impl) {
    JLOG_WARN("Unable to set ICE attributes, candidates gathering already started");
    return JUICE_ERR_FAILED;
}

agent_set_local_ice_attributes will refuse to set ice_ufrag and ice_pwd.

paullouisageneau commented 1 month ago

The logic is that you should not modify the local description once the connection process is started. The core issue is that node-datachannel's polyfill starts the connection immediately, createOffer() and setLocalDescription() are basically useless. See related answer in https://github.com/paullouisageneau/libdatachannel/issues/1218#issuecomment-2192567266