Skip to content

Experimental: Add grpc-web HTTP client #2174

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

Closed

Conversation

johanbrandhorst
Copy link
Contributor

This client is only enabled when gRPC-Go is built with GOARCH=WASM and GOOS=js. It is a spec-compliant gRPC-Web client.

I have been experimenting with a gRPC-web client written with Go and WASM, which culminated in https://github.com/johanbrandhorst/grpc-wasm, but I thought I could do one better. The idea is to have a program that works both when compiled normally and when compiled to WASM. This client is HTTP based and uses the WASM specific Fetch API based http.RoundTripper added in golang/go#25550.

I realise this will probably never be merged, but it's been a fun experiment, and in my testing both unary and server side streaming requests work. I've created a repo for testing this which can be found here: https://github.com/johanbrandhorst/wasm-experiments/tree/master/grpc. The demo showcases 2 unary request responses and 1 server streaming request response stream. It shows the successful parsing of gRPC status errors.

I mentioned this experiment to @jadekler on the Gophers Slack, and also this could probably be implemented much easier if #2112 was fixed.

@johanbrandhorst
Copy link
Contributor Author

johanbrandhorst commented Jun 25, 2018

I tested this against an Improbable gRPC-Web proxy with improbable-eng/grpc-web#213 applied. It currently only builds against tip of Go.

This client is only enabled when gRPC-Go is built with
GOARCH=WASM and GOOS=js. It is a spec-compliant
gRPC-Web client.
@johanbrandhorst
Copy link
Contributor Author

@johanbrandhorst
Copy link
Contributor Author

I made this a little bit easier with a separate repo: https://github.com/johanbrandhorst/grpcweb-wasm-example.

@dfawley
Copy link
Member

dfawley commented Jul 9, 2018

Thanks, this is very cool! However, I don't think we want to merge something like this in its current form, but rather wait for the redesign mentioned in #2112 and then implement something using that system instead. I'm working on that right now and hope to have something to share in the next couple weeks. I will close this PR in the meantime, but thank you again for sharing it.

@dfawley dfawley closed this Jul 9, 2018
@johanbrandhorst
Copy link
Contributor Author

Cool, I eagerly await updates on #2112 then :).

@johanbrandhorst johanbrandhorst deleted the add-grpc-web-client branch July 10, 2018 08:19
@johanbrandhorst johanbrandhorst restored the add-grpc-web-client branch July 10, 2018 08:19
@lock lock bot locked as resolved and limited conversation to collaborators Jan 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants