WebRTC App doesn't work while an iPhone or MacBook is connected.

Good evening, I am having problems with my WebRTC application when an iPhone or Macbook is connected. This only happens when an iPhone or Macbook is connected, as tests with Windows or Android devices have shown no issues.

As can be seen in the screenshot below, it appears that the datachannel is not initialised correctly. In fact, the webcam and microphone do not work even if permissions are given by the user, and messages and the remote webcam are not sent/shown.

If I open chrome console on Windows, this is the error I get in the console

Could you please help me investigate this problem. If you want, you can have full access to my application at https://www.fourmeet.it. I attach the functions that seem to be responsible for the problems:

  const configuration = {
    iceServers: [...turnServers, { urls: 'stun:stun.1und1.de:3478'}],
    iceTransportPolicy: 'relay'
  };

  peerConection = new RTCPeerConnection(configuration);

  dataChannel = peerConection.createDataChannel("chat");

  peerConection.ondatachannel = (event) => {
    const dataChannel = event.channel;

    dataChannel.onopen = () => {
      console.log("peer connection is ready to receive data channel messages");
    };

    dataChannel.onmessage = (event) => {
      console.log("message came from data channel");
      const message = JSON.parse(event.data);
      ui.appendMessage(message);
    };
  };

  peerConection.onicecandidate = (event) => {
    console.log("geeting ice candidates from stun server");
    if (event.candidate) {
      // send our ice candidates to other peer
      wss.sendDataUsingWebRTCSignaling({
        connectedUserSocketId: connectedUserDetails.socketId,
        type: constants.webRTCSignaling.ICE_CANDIDATE,
        candidate: event.candidate,
      });
    }
  };

  peerConection.onconnectionstatechange = (event) => {
    if (peerConection.connectionState === "connected") {
      console.log("succesfully connected with other peer");
    }
  };
  const stringifiedMessage = JSON.stringify(message);

  if (dataChannel && dataChannel.readyState === 'open') {
    dataChannel.send(stringifiedMessage);
  } else {
    console.log('canale non aperto');
  }
};
WebRTC App doesn't work while an iPhone or MacBook is connected.
 
 
Q