Skip to content

Support for wasm #661

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

Open
trojek opened this issue Feb 16, 2021 · 19 comments
Open

Support for wasm #661

trojek opened this issue Feb 16, 2021 · 19 comments
Assignees
Labels
feature New feature request

Comments

@trojek
Copy link

trojek commented Feb 16, 2021

Feature Request

Support for WebAssembly

Use Case:

Use NATS from browser without using JS binding.

Proposed Change:

Add support for wasm.

Who Benefits From The Change(s)?

People who want to use NATS in WebAssembly.

Alternative Approaches

Use JS binding.

@trojek trojek added the feature New feature request label Feb 16, 2021
@cameronbraid
Copy link

Another important use case is to write a Envoy Proxy Filter https://istio.io/latest/docs/concepts/wasm/

@john-livelyvideo
Copy link

any headway on this front?

@derekcollison
Copy link
Member

We have looked a bit at getting a port running under TinyGo. What specific use case are you looking for in the browser? I believe you can compile to wasm now and the Go client has websocket support, so wanted to make sure I understood the ask.

@john-livelyvideo
Copy link

john-livelyvideo commented May 9, 2022

@derekcollison I'm simply trying to figure out if it's possible to run golang/webassembly in the web browser, while using the go websocket client.

@derekcollison
Copy link
Member

Not sure if that would be a good experience over the TS/JS client or not. I think you would need to bridge to JS for access to the websocket IIRC.

@john-livelyvideo
Copy link

All we need is a generic interface for sending/recv'ing websocket frames which works both natively and in the browser, right?

https://natsio.slack.com/archives/CM3T6T7JQ/p1652115060809699?thread_ts=1652109614.003509&cid=CM3T6T7JQ

@john-livelyvideo
Copy link

there are a slew of other languages which compile to wasm in the browser (ie c#, rust, assemblyscript, c++, etc.), using golang would be my preferred way of bridging over to them via a homegrown local event bus which runs in the browser.

@derekcollison
Copy link
Member

@gedw99 the TS/JS clients can do the same. I believe you would need to jump through to JS to access the websocket from the TS/JS client regardless. But I could be wrong.

@john-livelyvideo
Copy link

@derekcollison that is correct, but that's a pretty simple interop between golang/js, right? per the framing i mentioned earlier?

@john-livelyvideo
Copy link

@derekcollison
Copy link
Member

Will take a look, thanks.

@derekcollison
Copy link
Member

I am supportive of getting the client to compile under TinyGO, or have another client targeting it. I believe the only thing is the encoded connections and GOB IIRC.

@caspervonb
Copy link
Contributor

caspervonb commented Jul 14, 2022

Unfortunately this might not be feasible at this time due to upstream blockers.

It seems that TinyGo doesn't support some of the prerequisite runtime functionality needed, such as timers (tinygo-org/tinygo#1037) so ultimately I don't think it's feasible to implement this without having a specialized implementation that avoids the use of those runtime calls completely.

@derekcollison
Copy link
Member

There will be a TinyGo client in the future.

@lynic
Copy link

lynic commented Jan 24, 2025

Is there any plan to support wasm with websocket?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

10 participants