Unity-Technologies / com.unity.webrtc

WebRTC package for Unity
Other
738 stars 186 forks source link

[BUG]: Unable to connect streams between two devices with relay-only mode forced #1029

Open BigETI opened 2 months ago

BigETI commented 2 months ago

Package version

3.0.0-pre.7

Environment

* OS: Tested on latest versions of *iOS*, macOS, and Windows
* Unity version: 2023.2.0f1

Steps To Reproduce

Set RTCConfiguration.iceTransportPolicy, to RTCIceTransportPolicy.Relay during RTCPeerConnection instantiation.

Current Behavior

Audio, data, and video streaming does not always work across different networks.

Expected Behavior

Audio, data, and video streaming works across different networks.

Anything else?

I am unable to connect audio, nor video streams, with relay-only mode forced.

The reason why I have forced relay mode is, because in many scenarios, peer-to-peer communication is not possible, therefore needs to be able to stream audio, video, and data through relay, (TURNS) as well as peer-to-peer. (STUN/TURN)

The initial issue with audio, video, and data streaming was, that for example on different networks, streaming would not always work, and on mobile, even less.

For testing purposes, I was able to isolate the issue with streaming, by forcing streaming to relay mode. (RTCConfiguration.iceTransportPolicy is set to RTCIceTransportPolicy.Relay) That made even local network streaming impossible. (Peer-to-peer)

I want to ensure, that the Unity WebRTC implementation works through different networks. To test, if the issue was with AWS, we have tested signaling, and RTC through example native iOS apps, which worked flawlessly.

The idea of TURN/TURNS is, to solve the issue with, whenever peer-to-peer is not possible, by relaying streams.

ICE servers, with correct authentication are specified, and awaited till negotiation is needed, in order to create an offer, and connect to a signaling server. (Session descriptions are empty, if offers are created outside RTCPeerConnection.OnNegotiationNeeded, after it being invoked. This is a different issue for sure) Session descriptions, and ICE candidates are correct, and successfully exchanged through a signaling server, provided by AWS. From observation, for example the received video stream is reported to be empty, if connection is relayed.