`websocket_websys` does not work in NodeJS environments
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.6k
- Forks
- 1.3k
- Avg merge
- 8h 47m
- Merged PRs (30d)
- 19
Description
Summary
I am currently trying to write a module that relies on libp2p with a websocket connection between the client (uses WASM) and server (uses normal Rust), while doing so I have realized that the websocket_websys package seems to be incompatible with the nodejs target, considering that WebSocket is not natively available. I receive the error OutgoingConnectionError { connection_id: ConnectionId(1), peer_id: None, error: Transport([("/ip4/127.0.0.1/tcp/4088/ws", Other(Custom { kind: Other, error: Other(Right(Left(Left(Error { msg: "Invalid websocket url: ws://127.0.0.1:4088/" })))) }))]) }. I believe this is because the API simply doesn't exist.
Trying to crudely shim API does not help. Any help would be appreciated (or alternative nodejs compatible transports)
Expected behavior
Able to connect via websockets between server and client.
Actual behavior
Error out when trying to import with WASM seemingly crashing (?)
Relevant log output
No response
Possible Solution
Referencing the ws crate instead of WebSocket would be a possibility (or isomorphic-ws), but that would require external dependencies.
Version
0.53.2
Would you like to work on fixing this bug ?
Yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the websocket_websys package and reproduce the reported ws://127.0.0.1:4088/ failure when targeting NodeJS/WASM. Compare the available WebSocket API with the mentioned ws or isomorphic-ws alternatives; done means a WASM client can connect to the Rust server over websockets in a NodeJS environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, rust, wasm
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100