# Multiple webrtc servers/workers with 1 port?

**URL:** https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669
**Category:** mediasoup libraries
**Created:** [May 13, 2025, 2:17am UTC](https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669 "2025-05-13T02:17:01Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![namnm](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/namnm/32/667_2.png) [@namnm](https://mediasoup.discourse.group/u/namnm)
#### Post date: [May 13, 2025, 2:17am UTC](https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669/1 "2025-05-13T02:17:01Z")

</div>

It is really good to have webrtc server, but it limits to 1 worker/cpu per server/port.  
I hope to have multiple workers working on 1 single port.  
Then we would listen on 443, with vertical scaling ready.

If it is not supported yet, do we have plan to do so, or it is technically not possible?

---

<div class="post-metadata">

### Author: ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)
#### Post date: [May 13, 2025, 5:41am UTC](https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669/2 "2025-05-13T05:41:25Z")

</div>

1 Worker == 1 separate process. Cannot listen in same port (despite its possible in Linux) because connections must be handled by a single Worker and not by anyone.

---

<div class="post-metadata">

### Author: ![namnm](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/namnm/32/667_2.png) [@namnm](https://mediasoup.discourse.group/u/namnm)
#### Post date: [May 18, 2025, 9:29am UTC](https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669/3 "2025-05-18T09:29:14Z")

</div>

> despite its possible in Linux

I guess we need to rewrite most of the things to get it done properly. As I understand, we just need to pass the data around processes, and that could be very difficult with cpp.  
I have seen a lot of code being written in rust, if we can completely rebind or rewrite it to rust, would it be easier than cpp to add support for this?

---

<div class="post-metadata">

### Author: ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)
#### Post date: [May 18, 2025, 9:43am UTC](https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669/4 "2025-05-18T09:43:40Z")

</div>

Honestly making meriapsup be able to listen on a single UDP and TCP port across different workers/processes is not a goal. mediasoup is efficient thanks to its single thread design, we don’t want to change that just to make it easier for the parent application to handle listening ports. Honestly it’s not that hard to program an application that opens and managed more than one port.

---

<div class="post-metadata">

### Author: ![namnm](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/namnm/32/667_2.png) [@namnm](https://mediasoup.discourse.group/u/namnm)
#### Post date: [May 19, 2025, 7:47pm UTC](https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669/5 "2025-05-19T19:47:35Z")

</div>

Thanks for being clear. More about the idea for this, it is not about parent application to manage more than one port, but:

- TURN server is needed to support strict NAT users where they can only access port 80, or 443 with TLS. Like a lot of big org or gov have those kinds of strict access rule.
- Some security certificates like ISO or SOC, are not happy about opening a lot of ports.

---

<div class="post-metadata">

### Author: ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)
#### Post date: [May 20, 2025, 8:02am UTC](https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669/6 "2025-05-20T08:02:06Z")

</div>

You can deploy a single TURN server listening in TLS port 443 and make it communicate with N mediasoup workers. This is a common setup.

---

<div class="post-metadata">

### Author: ![miroslavpejic85](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/miroslavpejic85/32/1044_2.png) [@miroslavpejic85](https://mediasoup.discourse.group/u/miroslavpejic85)
#### Post date: [May 24, 2025, 11:55pm UTC](https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669/7 "2025-05-24T23:55:52Z")

</div>

> [@ibc](#):
>
> You can deploy a single TURN server listening in TLS port 443 and make it communicate with N mediasoup workers.

So if I understand correctly, this involves:

- Configuring **mediasoup server-side transports** with `iceServers`
- Passing the same TURN credentials to the **client-side**

### 🔹 Server-side (Node.js with mediasoup)

When creating a WebRTC transport on the server include TURN credentials:

```js
const webRtcTransportOptions = {
  enableTcp: true,
  preferUdp: false,
  initialAvailableOutgoingBitrate: 1000000,

  // Add TURN server(s) here
  iceServers: [
    {
      urls: 'turns:your-domain.com:443?transport=tcp',
      username: 'webrtc',
      credential: 'turnpassword'
    }
  ]
};

```

Make sure:

- The TURN server is reachable on **port 443 over TCP/TLS**

* * *

### 🔹 Client-side (mediasoup-client)

On the client, when creating transports with `device.createSendTransport()` or `device.createRecvTransport()`, include the same `iceServers`:

```js
const transport = device.createSendTransport({
  id,
  iceParameters,
  iceCandidates,
  dtlsParameters,

  // Same TURN config as on the server
  iceServers: [
    {
      urls: 'turns:your-domain.com:443?transport=tcp',
      username: 'webrtc',
      credential: 'turnpassword'
    }
  ]
});

```

* * *

---

<div class="post-metadata">

### Author: ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)
#### Post date: [May 27, 2025, 1:42am UTC](https://mediasoup.discourse.group/t/multiple-webrtc-servers-workers-with-1-port/6669/8 "2025-05-27T01:42:19Z")

</div>

Multiple processes listening to a single port with the potential of sniffing and hijacking is never a good idea. Media soup can’t work this way and if it could doesn’t mean it should. These limits are set by operating system and should not even be experimented with.

Cheers.
