# Multiple client-side WebRtcTransports pointing a single server-side WebRtcTransport

**URL:** <https://mediasoup.discourse.group/t/multiple-client-side-webrtctransports-pointing-a-single-server-side-webrtctransport/3832>\
**Category:** mediasoup libraries\
**Created:** [January 18, 2022, 4:33pm UTC](https://mediasoup.discourse.group/t/multiple-client-side-webrtctransports-pointing-a-single-server-side-webrtctransport/3832 "2022-01-18T16:33:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![piranna](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/piranna/32/934_2.png) [@piranna](https://mediasoup.discourse.group/u/piranna)\
**Post date:** [January 18, 2022, 4:33pm UTC](https://mediasoup.discourse.group/t/multiple-client-side-webrtctransports-pointing-a-single-server-side-webrtctransport/3832/1 "2022-01-18T16:33:02Z")

</div>

According to [Split sender and receiver Transport classes · Issue #686 · versatica/mediasoup · GitHub](https://github.com/versatica/mediasoup/issues/686#issuecomment-947098532), mediasoup-client and libmediasoupclient objects are unidirectional just only due to complexities in management of bi-directional SDPs. Not fully sure if due to a misunderstood, but I’ve created with mediasoup-client both a WebRTCSendTransport and a WebRtcRecvTransport, and server side a single WebRtcTransport object.

After that, I registered the `connect` event in both clients to send their `dtlsParameters` parameters to the server and there call to `connect()` method. First one works, but second ones throw an error about Transport already connected. If I don’t register the `connect` event in the second client-side Transport (the sender one), I get an error about not being registered, so I just register a dumb handler that just call the callback as a sucesfully connection… and seems to work 🙂 or at least I can get video flowing in.

I still needs to check if I can send data too, but in any case it seems a bit hacky to me, so I want to ask: does it makes sense what I’m doing? I’ve just reviewed the sent info and seems to me there’s nothing related the Transport is intended to receive or send info (maybe the `role` field?):

```auto
424["transport_connect",{"transportId":"3b652ddc-2103-470a-82cd-95077545baa1","dtlsParameters":{"role":"client","fingerprints":[{"algorithm":"sha-256","value":"11:F7:9D:56:26:24:E8:07:9E:7F:B9:8B:D6:3C:B3:1F:82:7F:42:26:50:82:FE:42:1D:55:A2:3D:FB:44:22:1C"}]}}]

```

If this is a (hacky) valid use case, shouldn’t `connect()` method just ignore the second call instead of throwing an error? Should I capture and check it instead, in case there would have been any other error? Maybe detect that I’ve already called it once and don’t try to call it again?

---

<div class="post-metadata">

**Author:** ![snnz](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/snnz/32/693_2.png) [@snnz](https://mediasoup.discourse.group/u/snnz)\
**Post date:** [January 18, 2022, 6:02pm UTC](https://mediasoup.discourse.group/t/multiple-client-side-webrtctransports-pointing-a-single-server-side-webrtctransport/3832/2 "2022-01-18T18:02:48Z")

</div>

> [@piranna](#):
>
> I want to ask: does it makes sense what I’m doing?

No, it doesn’t. Where do you think the second client transport is connected to? There is a RTCPeerConnection inside, which is P2P by nature, it needs a dedicated peer on the other side.

---

<div class="post-metadata">

**Author:** ![piranna](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/piranna/32/934_2.png) [@piranna](https://mediasoup.discourse.group/u/piranna)\
**Post date:** [January 18, 2022, 6:10pm UTC](https://mediasoup.discourse.group/t/multiple-client-side-webrtctransports-pointing-a-single-server-side-webrtctransport/3832/3 "2022-01-18T18:10:02Z")

</div>

I know there’s a RTCPeerConnection object inside each mediasoup-client WebRtcTransport, but I’ve already exchanged the rtpCandidates and didn’t find any issue on that, just only with the `connect` event. Do you mean that since I have two unidirectional RTCPeerConnection objects on client side, I’m forced to create two WebRtcTransports on the server too?

---

<div class="post-metadata">

**Author:** ![copiltembel](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@copiltembel](https://mediasoup.discourse.group/u/copiltembel)\
**Post date:** [January 18, 2022, 6:45pm UTC](https://mediasoup.discourse.group/t/multiple-client-side-webrtctransports-pointing-a-single-server-side-webrtctransport/3832/4 "2022-01-18T18:45:19Z")

</div>

> [@piranna](#):
>
> Do you mean that since I have two unidirectional RTCPeerConnection objects on client side, I’m forced to create two WebRtcTransports on the server too?

Yes, you do!

---

<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:** [January 18, 2022, 6:56pm UTC](https://mediasoup.discourse.group/t/multiple-client-side-webrtctransports-pointing-a-single-server-side-webrtctransport/3832/5 "2022-01-18T18:56:17Z")

</div>

It’s impossible that DTLS works for both client transports if there is a single transport in server side.

---

<div class="post-metadata">

**Author:** ![piranna](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/piranna/32/934_2.png) [@piranna](https://mediasoup.discourse.group/u/piranna)\
**Post date:** [January 18, 2022, 8:02pm UTC](https://mediasoup.discourse.group/t/multiple-client-side-webrtctransports-pointing-a-single-server-side-webrtctransport/3832/6 "2022-01-18T20:02:28Z")

</div>

Then I misunderstood your words, thanks to clarify @ibc, i’ll rewrite my code then. Is It posible to add some way to prevent that pitfall? Maybe a map on client side of hash of dtls to the WebRtcTransports? Or maybe better (or un addition to It) to add support for bidirectional ones?
