After creating a sendTransport and getting an audioTrack using getUserMedia, I am trying to have my sendTransport produce so that I can have a producer. However, I am not getting anything back.
I have read the documentation.
According to the documentation, it states that transport.on(‘connect’) will be emitted if it’s first time calling transport.produce() and transport.on(‘produce’) will be emitted if it’s not, in order to create Producer instance in the server-side.
However, when I call transport.produce(), let producer = await this.sendTransport.produce() to be exact, I am not getting anything. When I get rid of the await, I have transport.on('connect') emitted, but nothing further. I tried to look at the mediasoup-client source code, and I have found out that my code is not passing through safeEmitAsPromise
When I modified the example in mediasoup-demo, it worked perfectly fine, but I am getting this problem when I am trying to build my own.
I don’t fully understand the problem. You must set the sendTransport.on("connect") and sendTransport.on("produce") event listeners before you call sendTransport.produce() .
Thank you for your reply. I had actually previously set the event listeners after I call sendTransport.produce(). but it still does not work after I moved the event listeners after calling sendTransport.produce()
oh shoot there was a typo. I have set the event handlers before calling produce() like you have said, but it is still not working properly.
---- update
I think I got it to work.
I am now calling produce() after sendTransport and recvTransport are created.
I see that sendTransport.on('connect') is firing, but I still cannot see the producer in the client side.
Below is my code;