Code Monkey home page Code Monkey logo

Comments (10)

Blancduman avatar Blancduman commented on June 10, 2024

Hello. Write in more detail about your problem, the scenario of its execution and environment. Validate your incoming consumer data.

from mediasoup-client-flutter.

un-hongly avatar un-hongly commented on June 10, 2024

@Blancduman
Thank you for your reply,

It happens on both Android and iOS. The scenario is that I have 2 producers (video & audio) that need to be consumed so I create 2 ReceiveRransport to consume those producers.

My code of consuming part is something like this:

 
Socket.connection.emitWithAck('consume', {
      'peerId': participantId,
      'transportId': recvTransport.id,
      'producerId': producerId,
      'rtpCapabilities': _device.rtpCapabilities.toMap(),
    }, ack: (response) async {
      recvTransport.consume(
          id: response['id'],
          peerId: response['id'],
          producerId: response['producerId'],
          kind: RTCRtpMediaTypeExtension.fromString(response['kind']),
          rtpParameters: RtpParameters.fromMap(response['rtpParameters']),
          accept: () {});
    });

The parameters that I passed to .consume(...) are correct but after .consume() is called it throws an error randomly saying that "Null check operator used on a null value". I traced the error log I found that this code await _pc!.setRemoteDescription(offer); throw an error because occasionally it has null value.

This is the full log from debug console:
logs.txt

from mediasoup-client-flutter.

un-hongly avatar un-hongly commented on June 10, 2024

@Blancduman

I look into mediasoup_client_flutter/…/handlers/unified_plan.dart file and found the Future<HandlerReceiveResult> receive(HandlerReceiveOptions options) method is being invoked before peerConnection is ready.

  @override
  Future<HandlerReceiveResult> receive(HandlerReceiveOptions options) async {
    ...
    _pc!.setRemoteDescription(offer);
    ...
  }

Screen Shot 2022-06-30 at 7 01 58 PM

I found this information on mediasoup website he said "It receives a RTP packet of the new consumer before the remote RTCPeerConnection is ready to process it." and he recommended setting paused: true on first to prevent this but somehow still Future<HandlerReceiveResult> receive(HandlerReceiveOptions options) method is being invoked before peerConnection is ready and caused the error.

from mediasoup-client-flutter.

Blancduman avatar Blancduman commented on June 10, 2024

Try the next one:

  1. accept should be callback function that comes from your response. Call it, when you ready to consume, from function that you passed to recvTransport consumer callback.
  2. Weird, but still, check your appData. I don't know how your backend work, so maybe your backend depend on some data inside appData. (case from my experience).
  3. Permissions? (hehe)

Really complicate to tell for me, without whole pipeline. Ignoring what I wrote above, everything look good. Maybe you missed step in loading device? but that happens randomly.

from mediasoup-client-flutter.

un-hongly avatar un-hongly commented on June 10, 2024

@Blancduman

  1. accept is from the server side ?
  2. I didn't use any appData any data. 😄
  3. I doubled check permissions are good.

Actually, it's not random it happens every time on the app first run because PeerConnection needs time to be ready before it can be used by this function Future<HandlerReceiveResult> receive(HandlerReceiveOptions options) but it was triggered before PeerConnection is ready that is why it throws an error. What causes the receive function to be triggered?

Well, I think it will produce an error when trying to consume producers after app fresh run. So I ran [mediasoup_client_flutter_example](https://github.com/Blancduman/mediasoup_client_flutter_example) trying to see its behavior but I can't join an existing room. The roomId always shows null even if I input a valid room id. Could you help look into that?

from mediasoup-client-flutter.

Blancduman avatar Blancduman commented on June 10, 2024

You should put whole link to example.

Without code, I can't tell much. Maybe you forget await somewhere.

from mediasoup-client-flutter.

Blancduman avatar Blancduman commented on June 10, 2024

About accept, check mediasoup demo (js version)

from mediasoup-client-flutter.

un-hongly avatar un-hongly commented on June 10, 2024

@Blancduman Thank for your reply. I've been testing with remote mediasoup server and it's working fine but not with local.

  • Senario 1 (Error)
    Running local mediasoup server on my Mac machine also Peer1 on the same machine then Peer2 running on my mobile phone it produces the error.

  • Senario (No Error)
    Running a remote mediasoup server on AWS. Peer1 on a Mac machine then Peer2 running on my mobile phone it doesn't produce the error.

I still can't figure out why this happened. Maybe Peer1 and server have the same IP address? I will test more to see if it will happen after using a remote server too or not.

from mediasoup-client-flutter.

ollyde avatar ollyde commented on June 10, 2024

@un-hongly I have the same issue, did you find out how to fix it?

from mediasoup-client-flutter.

un-hongly avatar un-hongly commented on June 10, 2024

@un-hongly I have the same issue, did you find out how to fix it?

I still haven't found any solution yet but as I said above when I test it with the remote server it rarely to happens but with the local server it occur every time my app fresh start.

from mediasoup-client-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.