question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

We don't handle `channelId` correctly

See original GitHub issue

Expected behavior

RTCPeerConnection pc = xxx;
const channel1 = pc.createDataChannel("label1", {maxRetransmits: 0, ordered: false});
channel1.onopen = xxx; // should be called
const channel2 = pc.createDataChannel("label2", {maxRetransmits: 0, ordered: false});
channel2.onopen = xxx; // should be called

Observerd behavior

Only first channel can receive state change event.

Steps to reproduce the problem

Just create multiple data channels in iOS, with react-native-webrtc >= 1.75.3

Platform information

  • React Native version: 0.63.3
  • Plugin version: 1.75.3
  • OS: iOS
  • OS version: 10

There is already a PR try to resolve this issue: https://github.com/react-native-webrtc/react-native-webrtc/pull/726 . However it didn’t fix the problem completely. Based on the discussion, I found that in the PR, aka commit f3736ed, those guys introduced checking for negotiated. If negotiated == false, id will be reset to -1. And in the following method AllocateSid, it will try to run potential_sid += 2;. So when - (void)dataChannelDidChangeState:(RTCDataChannel*)channel is called, channel.channelId had been changed, and different from what we recorded in peerConnection.dataChannels which is done in createDataChannel:(nonnull NSNumber *)peerConnectionId label:(NSString *)label config:(RTCDataChannelConfiguration *)config. This negotiated logic still exists in the newest master branch of webrtc.

Previously, our team used react-native-webrtc@1.69.2, which rely on [M69](https://github.com/jitsi/webrtc/tree/cb536cf7a368e77ec29a6779de7fbebf2c300b70), checking the datachannel.cc in that commit, there is not negotiated logic, so everything is happy back on that time.

This PR seems to work for one channel, because it changes the id generation to start from 1 instead of 0, which coincidently matches the id generated in webrtc sdk.

I don’t have enough knowledge on webrtc and negotiated flag. What should be a correct fix for this?

Currently, in order to be able to use multiple channels, you can try to manually assign ids to your data channels, start from 1, and +2 for each. Which means:

const channel1 = pc.createDataChannel("label1", {id: 1, maxRetransmits: 0, ordered: false});
const channel2 = pc.createDataChannel("label1", {id: 3, maxRetransmits: 0, ordered: false});
const channel3 = pc.createDataChannel("label1", {id: 5, maxRetransmits: 0, ordered: false});

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
xilincommented, Dec 16, 2020

@saghul I’ll try to submit a PR in the weekend.

0reactions
Minishlinkcommented, Apr 1, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Channel ID/GUID is identical, but the error saies
Solved: Hello everybody! I have a strange error, when adding a tab to a channel in Teams. The error is this: { "statusCode"...
Read more >
Question about using YouTube handles - Google Support
I just setup my YouTube branded channel handle (@rickfromjersey) and when I visit using the handle address the main page comes up correct, ......
Read more >
How can I get a channel ID from YouTube? - Stack Overflow
Yes. If your trying to get your Channel ID ou Account ID, and you don't have an account or channel, both will not...
Read more >
channel ID - AWS Elemental MediaLive API Reference
The name of the audio selector in the input that MediaLive should monitor to detect silence. Select your most important rendition. If you...
Read more >
How to generically access user id and channel id in Global ...
I want to have a global middleware be able to respond back to the user ... have `channel.id`, some have `channel_id`, some don't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found