# Error: connect() already called

**URL:** <https://mediasoup.discourse.group/t/error-connect-already-called/870>\
**Category:** mediasoup libraries\
**Created:** [April 24, 2020, 1:05pm UTC](https://mediasoup.discourse.group/t/error-connect-already-called/870 "2020-04-24T13:05:48Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jbis9051](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@jbis9051](https://mediasoup.discourse.group/u/jbis9051)\
**Post date:** [April 24, 2020, 1:35pm UTC](https://mediasoup.discourse.group/t/error-connect-already-called/870/3 "2020-04-24T13:35:21Z")

</div>

> The issue is in server side. Obviously you are calling `connect()` multiple times in the same server side transport. You must create a **new** server side transport for each client side transport, you cannot reuse them.

I think I am.

> In your code snippet above you are using the **same** transport in client side for audio and video, which is fine, and not two transports.

On the other thread [Error: connect() already called](https://mediasoup.discourse.group/t/error-connect-already-called/59) you say

> That’s indeed a bug in your code since you are creating separate send transports for audio and video.

I have posted the same code (just as an example here). How is it different?

* * *

There are two issue at hand here.

1. Based on the code snippet, I don’t think `connect()` should be being called twice. Since transports are refered to by id this shouldn’t be an issue:

> If startMic() and startWebcam() are called immediately one after the other, then two transports are created which leads to dual call to connectTransport().

startMic and startWebcam should crete unique id’s of transports. You _should_ be able to create a separate transport for audio and video if you like.

1. Regardless of the code on the client side, you should be able to check **server** side if `connect()` was called. If this check isn’t possible, then you are **trusting the client** not to call connectTransport twice. We shouldn’t _need_ to trust the client. There should be a mechanism server side to check if connect has been called to prevent an error from occurring.

---

_[View the full topic](https://mediasoup.discourse.group/t/error-connect-already-called/870)._
