Weird problem with WebSocket

Hello. I’m trying to run project on localhost (exactly like described in readme). Changed nothing except certificates (used self signed to run o localhost). So run both client and server on localhost. The platform is win 10 x64.
I get some low level websocket error 1006 when server tries to create a room. The request is “router.createPlainTransport”. So I get to kind of errors one by one but same nature:

  1. ERROR:Channel [pid:3264 RTC::PortManager::RTC::PortManager::Bind() | throwing MediaSoupError: uv_udp_init_ex() failed: invalid argument
    2)ERROR room creation or room joining failed:Error: uv_udp_init_ex() failed: invalid argument at Channel._processMessage (mediasoup\lib\Channel.js:206:37) at Socket. (mediasoup\lib\Channel.js:68:34) at Socket.emit (events.js:316:20) at Socket.EventEmitter.emit (domain.js:485:12) at addChunk (_stream_readable.js:297:12) at readableAddChunk (_stream_readable.js:273:9) at Socket.Readable.push (_stream_readable.js:214:10) at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)

So basically error is “uv_udp_init_ex() failed: invalid argument”. Any idea?

ok I did some investigation. The problem caused by commit 50fae4b is made 3 days ago

Enable UV_UDP_RECVMMSG: - Upgrade libuv to 1.37.0. - Use uv_udp_init_ex() with UV_UDP_RECVMMSG flag. Also fixes #384 by adding our own uv.gyp file

So take a look on file win/udp.c:

int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) {
int domain;

/* Use the lower 8 bits for the domain */
domain = flags & 0xFF;
if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC)
return UV_EINVAL;

if (flags & ~0xFF)
return UV_EINVAL;

You call this only once :
err = uv_udp_init_ex(DepLibUV::GetLoop(), reinterpret_cast<uv_udp_t*>(uvHandle), UV_UDP_RECVMMSG);

UV_UDP_RECVMMSG is 256, so in this case

if (flags & ~0xFF)
return UV_EINVAL; - always gives invalid argument invalid argument error.

Any quick fix?

It’s a bug in libuv v1.37.0:

I assume they’ll fix it soon, otherwise we’ll do a hack in mediasoup. For now please use mediasoup 3.5.7 (avoid 3.5.8).

1 Like

Workaround done in mediasoup 3.5.9 until libuv fixes its bug.

1 Like