Error: connect() already called

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 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.