Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Web Assembly #1803

Closed
DAOCUONG opened this issue Nov 12, 2023 · 9 comments
Closed

Build Web Assembly #1803

DAOCUONG opened this issue Nov 12, 2023 · 9 comments

Comments

@DAOCUONG
Copy link

DAOCUONG commented Nov 12, 2023

Try to run :

rustup target add wasm32-unknown-unknown
cargo build --release --target wasm32-unknown-unknown

Got error with mio 

ener.rs:103:18
    |
103 | ...   sys::tcp::accept(inner).map(|(stream, addr)| (TcpStream::from_std(stream), addr))
    |            ^^^ could not find `tcp` in `sys`

error[E0433]: failed to resolve: could not find `udp` in `sys`
   --> /Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.9/src/net/udp.rs:122:14
    |
122 |         sys::udp::bind(addr).map(UdpSocket::from_std)
    |              ^^
@github-project-automation github-project-automation bot moved this to 📋 Backlog in iroh Nov 12, 2023
@dignifiedquire
Copy link
Contributor

Currently iroh is not compatible with wasm building. There are multiple dependencies (like quinn) and internal code that need to first change to support it.

@amiyatulu
Copy link

Quinn recommends WebTransport for browser WebAssembly environment.

@dpc
Copy link

dpc commented Jun 26, 2024

Quinn recommends WebTransport for browser WebAssembly environment.

Last comment in that thread says:

There are now implementations of WebTransport that use Quinn, e.g. https://github.com/kixelated/webtransport-rs. Quinn is a QUIC implementation, and WebTransport is built on top of (HTTP/3 which is built on top of) QUIC.

And https://developer.chrome.com/docs/capabilities/web-apis/webtransport indicates that all major browsers other than Safari support it now.

So ... how more or less one would go about it?

@Voronar
Copy link

Voronar commented Jun 26, 2024

Does WebTransport allow a browser side be a server part of the WebTransport protocol? If no, then how iroh would work in the browser environment? As I know iroh node is a "client" and a "server" at the same time. I suppose it will work only as a client. In theory WebRTC may help, but in that case non-browser iroh node should support 2 communication protocols at the same time QUIC and WebRTC, that is problematic.

@matheus23
Copy link
Contributor

We have a plan for getting iroh to

  1. compile to wasm and
  2. work in the browser via wasm_bindgen.

But for the first iteration - that will require that the browser node is permanently connected to an iroh relay node & forwarding traffic over that.

IIUC (I'm fairly new to the project), @Voronar is spot on. Our current plan is websockets + relay, and later potentially trying WebRTC data channels for peer-to-peer connections. Some of us have looked at WebTransport and found that it probably won't work.

@amiyatulu
Copy link

As I know iroh node is a "client" and a "server" at the same time

How does webtorrent works? Is it not client and server at the same time?

@amiyatulu
Copy link

amiyatulu commented Jul 1, 2024

Also wasm doesn't mean only for browser environment, Iroh need to also support edge serverless computing like wasmedge, spin or everywhere computer

@DougAnderson444
Copy link

work in the browser via wasm_bindgen.

We did this with rust-libp2p and it works pretty well.

I'm here because I stumbled upon Willow which is apparently partially implemented in iroh which is cool.

Ideally I'd use the iroh willow portions but most of my current connecting and networking is built in libp2p over webRTC though, as I want the ability to connect the browser to "the node", whatever the node shall be.

On the server side you might consider str0m for WebRTC as it's sans-io, though less mature than webrtc-rs it may be easier to work with in the long run.

One last random point that I'll note on wasm is that we will eventually be moving toward WebAssembly Component Model which uses wasm interface types (WIT) which is what spin and everywhere comp are built upon. It's still early (v0.2.0) but it might be worthwhile to look down the road at what Wasm is going to look like in a year or two and design around that.

@matheus23 matheus23 changed the title Build Web Assemply Build Web Assembly Jul 24, 2024
@matheus23
Copy link
Contributor

Closing in favor of a unified issue: #2799

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in iroh Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

7 participants