Why I get transport close event automatically in 15s from the starting?

Bug Report

Your environment

  • Operating system: Ubuntu
  • Node version: 23
  • npm version: 0.9
  • gcc/clang version: no need
  • mediasoup version: 3.16.0
  • mediasoup-client version: 3.11.0

Issue description

I started mediasoup server with express backend and started video streaming. while 15s first, I can see my video and then automatically I got ‘Producer transport closed’ and can’t see my video. Please help me fix that asap. Very urgent issue.

Thanks

Hi amg, rather than a bug, this is most likely a misconfiguration on your end.


This issue is most likely caused by a firewall or NAT configuration problem that’s blocking the RTP ports used by mediasoup. Here’s how to troubleshoot and resolve it:


:white_check_mark: 1. Firewall Configuration

Ensure the UDP/TCP port range specified in your mediasoup config (typically 40000–49999) is open on:

  • Your server’s local firewall (e.g., iptables, ufw)
  • Any cloud provider’s network security group, such as AWS Security Groups or GCP firewall rules

:white_check_mark: 2. Correct announcedAddress (Public IP)

When your mediasoup server is behind NAT (e.g., Docker, EC2, VM), you must set the announcedAddress to your public IPv4 address so clients can reach the correct endpoint.

Example configuration:

webRtcTransportOptions: {
  listenInfos: [
    {
      protocol: 'udp',
      ip: '0.0.0.0',
      announcedAddress: 'your.public.ip.address',
      portRange: {
        min: 40000,
        max: 49999,
      },
    },
    {
      protocol: 'tcp',
      ip: '0.0.0.0',
      announcedAddress: 'your.public.ip.address',
      portRange: {
        min: 40000,
        max: 49999,
      },
    },
  ],
}

:small_blue_diamond: Note:

  • If you’re deploying on Amazon EC2, use your Elastic IP as the announcedAddress.
  • If you’re running mediasoup inside Docker, consider using network_mode: 'host' to avoid NAT issues.

:white_check_mark: 3. Transport Lifecycle Handling

The error 'Producer transport closed' usually means the transport was unexpectedly terminated, which is often a result of network issues like blocked or unreachable RTP ports. The above steps typically resolve this.


:counterclockwise_arrows_button: Final Step: Restart

After applying the changes, restart your mediasoup server to apply the updated configuration.