react-native-webrtc: Unable to set up peer connection
Peer A joined in first, uses react-native-webRTC . Peer B joined next, uses browser webRTC.
Expected Behavior:
RTCPeerConnection should set up properly in peer A, when peer B sends invite.
Observed Behavior:
RTCPeerConnection unable to set up in peer A. Throws exception:
com.facebook.react.bridge.UnexpectedNativeTypeException: Value for iceServers cannot be cast from ReadableNativeMap to ReadableArray
Steps to reproduce the issue:
Upgrade react-native from 0.66.5 to 0.70.5, duly and manually following required steps in upgrade helper. (These include some breaking changes, like hermes-engine, new architecture support, ndk, cmake upgrades, etc.,.).
Develop webRTC module, with socket integration, as documented.
Refresh node_modules, and builds.
Run app, go to webRTC module. Join as peer A.
Let other peer B join same room from browser end.
Platform Information
- React Native Version: 0.70.5
- WebRTC Module Version: 111.0.0, 111.0.3 (both tried)
- Platform OS + Version: Android 7 for peer A, chrome 114 for peer B
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19 (12 by maintainers)
Instead of this:
peerConnection = new RTCPeerConnection(this.#turnCredentials);I tried this:
peerConnection = new RTCPeerConnection({iceServers:[...this.#turnCredentials?.iceServers]});and found it fixed.
Looked into RTCPeerConnection.ts file in node_modules. Found problem regarding declaration file for module “react-native”, from which NativeModules is imported, which in turn sets up peer connection
That’s because the native function is sync. I don’t see anything obvious at a glance, I’ll take a closer look this week.
Part of the error message:
Seems to emerge with nativeCallSyncHook