Is there any webrtc library that supports compiling to wasi? Webrtc rust is not compiling because of socket2 and tokio. I need to impleament realtime audio communication.
I don't think so. (Don't take that as definitive.) For now at least I would suggest managing the WebRTC connection in JavaScript and ferry bytes across the JS/Wasm boundary.
Note that there are some examples of tokio that do work with wasi:sockets:
https://github.com/tokio-rs/tokio/pull/6893
There are other prototypes and experiments out there, but you may be able to get sockets & tokio working
There is also https://gist.github.com/pimeys/856846ff8718247d79f1557ed82d80f7
in short, we await v0.3.0.x for direct compilation here.
Ralph said:
in short, we await v0.3.0.x for direct compilation here.
I doubt 0.3.x will make any difference regarding wasi-sockets support in mio, tokio and socket2. There are no technical obstacles to supporting WASIp2 sockets in any of those libraries, and I don't expect WASIp3 sockets to be significantly more or less difficult to support in comparison. What might help is WASI 1.0, though -- it would be a sign of stability and make the platform more attractive to library maintainers.
Thank you for the suggestions and in my case where I am using wasm components as plugins and wasmtime as host and I cant really use web or host implementations but the good thing is as suggested, I can use the forks of tokio and socket2 which works with wasi sockets and by using them hopefully I should able to compile webrtc crate, which is perfect for my case as I needed plugin only implementation and using custom forks should be fine temporarily as I am using it for demo purposes only, tho it would be great if they get merged in crates itself.
Would be great if you shared that progress here (whatever you can open source) -- I'm sure people would love to :eye: :eye: the code!
I am not able to compile webrtc because of udp sockets, is udp not implemented yet for mio and tokio?
Sorry, no -- my mio PR only supports TCP sockets so far. Adding UDP support should be straightforward, though -- it's supported in wasi-libc, so it should just be a matter of hooking that up to mio.
Ah, that's unfortunate-but makes sense. Honestly, I'm not super deep into sockets or wasi-libc myself, so I might be missing some of the knowledge required there. If anyone more familiar with this stuff is up for it, a PR adding UDP support would be massively appreciated!
Last updated: Dec 06 2025 at 05:03 UTC