How to add media stream to a producer

I think the issue can come from the lib itself

I made it worked.
Now i have to scale it.

Thanks for the people who tried to help me :slight_smile:

Great, kindly share the issue and the way you solved for the help of others.

Yes i will, i think i will do a full tutorial of how to use mediasoup with front end framework like Angular and NestJS and redis as a message broker.
But it was late, i will do an explicite explanation.
I think my issue was the fact it wasn’t in order in consumer side because i had a lot of websocket event and redis messages that make me lost and made the code complexe.

Thanks for trying to help me.

I found an issue i tried to resolve since few hours, but when i jsut send video it work, and i receive only one time the video.
I receive one time video from the produce in consumer side.
Doing this:

async streamProduce(sendTransport: Transport<AppData>) {
    const videoProducer = await sendTransport.produce(this.videoProducer);
}

But when i add the audio like this:

  async streamProduce(sendTransport: Transport<AppData>) {
    const videoProducer = await sendTransport.produce(this.videoProducer);
    const audioProducer = await sendTransport.produce(this.audioProducer);
}

I received 2 times audio.
Someone have an idea ?

You might be consuming it twice or producing it twice, that is the only possibility.

Yes but when i produce twice video then audio, audio overload the video and i receive audio twice in consumer side

The answers to all of this is in your code brother, there is nothing in mediasoup itself that can cause this.

Yes don’t worry i can handle this my self.
Just to be sure, if i want to consume video and the audio of the video i have to create 2 consumer in consumer side ?

Yes a consumer is for one track, 1 consumer for 1 track. There can be multiple consumer per transports.

Yes i made it work thanks you, i was busy but managed to make it work.
What’s your approach to make it scalable ?
I have my method and the doc talk about it, but did you manage to scale your mediasoup server ?

Yes I have managed to scale it, yet to load test it. There are many topics in here regarding this, you can check them or may be open a new topic.

Yes i would.
I already have some ideas, but i tought it would be nice to share some technics to scale it.
For now i have a quality downgrade between my producer webcam quality and my consumer receiving the video.
So i try to find out how to improve the quality.

I have an issue, it’s not working on firefox for me.
Is it working on firefox for you ?

Does we need a TURN server for firefox ?
I had setup one but i still had my issue.

no it is not needed in normal conditions, check your iceServers details, the latest versions of browsers don’t allow query parameters in the urls, so make sure the urls doesn’t contain any query parameters.

Check for the errors on firefox.

So even without the iceServers it should work but it didn’t and i wasn’t using any query parameter

Ok there will be some other issue then, you need to check the errors in console, or see at which point it causes problem.

The issue come from when i want to produce and connect.
The connection failed and i have this error:

WebRTC: ICE failed, your TURN server appears to be broken, see about:webrtc for more details

btw i here is my iceServers array:

const iceServers = [
    { urls: ['stun:stun.l.google.com:19302'] },
    {   urls: ['turn:coturn:3478'], 
        username: 'username', 
        credential: 'password',
    },
];