transport.on('connect') not triggring the event


I am trying to connect to transport media and i am not getting any response from the backend and even while i log a message in the console

Front end code :

 async function getUserBroadcast(){
        let routerRtpCapabilities = await sendRequest('askRtpCapabilities',{})
        await device.load({routerRtpCapabilities});

        const data = await sendRequest('getCreateProducerTransport', {});
        console.log('transport params:', data);

        let newtransport = device.createSendTransport(data);
        newtransport.on("connect", async ({ dtlsParameters }, callback, errback) =>{
                console.log('transport is connected') 
                await sendRequest(
                    transportId    :, 
                    dtlsParameters : dtlsParameters

                // Tell the transport that parameters were transmitted.
            catch (error)
                // Tell the transport that something was wrong.

        newtransport.on('produce',async (
                { kind, rtpParameters },
            ) => {
                console.log('--trasnport produce');
                try {
                    const { id } = await sendRequest('produce', {
                    callback({ id });
                } catch (err) {
        newtransport.on('connectionstatechange', (state) => {
            switch (state) {
                case 'connecting':

                case 'connected':

                case 'failed':


Backend code:

socket.on('transport-connect', async (data, callback) => {
    await transport_Producer.connect({
    dtlsParameters: data.dtlsParameters,

The process for connecting DTLS is fairly straight forward and your front-end does demonstrate this in several steps but let’s summarize it.

  1. Client requests transport creation,
  2. Server creates transport and hands client DTLS and ICE;
  3. Client takes the DTLS and ICE parameters and creates transport with this.
  4. Client’s transport emit connect with responding DTLS to send to server
  5. Server connects this transport with provided DTLS.
  6. When all is finished server will emit dtlsstatechange and client will emit connectionstatechange

I would debug and determine if you’re stalling on steps and additionally check your network configurations as this will surely prevent connection from ever occurring if it’s wrong.

If you suspect code, trial a working demo.

hi CosmosisT,

Thanks for your answer i made sure that all the setps are done. i logged the transport object it works but when it comes to on connect event and on produce events nothing happen.

I think i don’t have any problem with my connection settings because i tried an open source mediasoup project and it works.


The transport does not require you to produce to it to connect, produce event fires off when track is ready and transport is opened in other words it can occur before/after emit of connect.

If you’re getting to the step you connect the transport on both server/client and nothing is happening I would think server-configurations.

Confirm the mediasoup client isn’t halting somewhere awaiting a response, this issue can be common for custom developments that don’t follow the awaitqueue procedure.

Do a bit of logging/debugging to trace where things get stuck and report back.


I fixed the problem transport conncet event or produce event are triggered when there an audio or a video to produce when i got my media ready and produced the events triggred.

Thanks again.

Connect should be established before/after produce order can vary however.

So it sounds like you’re fighting awaitQueue, you can modify client if it doesn’t comply properly to your app/client setup.