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

Should be able to alternate between grpc and http for jssdk compatibility #76

Closed
shravanshetty1 opened this issue May 31, 2021 · 13 comments

Comments

@shravanshetty1
Copy link

@mallochine

As jssdk is using gosdk as a wasm dependency, it will break since gosdk is going to start using grpc instead of http soon and browser clients do not support grpc even with wasm.

we can solve this by making gosdk use http/grpc based on some kind of configuration

Possible solution -

  • Add build arguement
@shravanshetty1
Copy link
Author

We could also consider - https://grpc.io/docs/platforms/web/ - https://github.com/improbable-eng/grpc-web.
We will need to use grpc-web and there needs to be a proxy between every service which convert grpc-web request to grpc. Since this is a distributed system this will be very expensive. Just sharing my thoughts.

@mallochine
Copy link
Contributor

mallochine commented Jun 3, 2021

How do you know grpc will break

https://github.com/johanbrandhorst/grpcweb-wasm-example
https://github.com/johanbrandhorst/grpcweb-wasm-example/tree/master/frontend/html

do you have a proof of concept (20-50 lines) proving golang => wasm that can't make grpc calls.

@shravanshetty1
Copy link
Author

@mallochine

We could also consider - https://grpc.io/docs/platforms/web/ - https://github.com/improbable-eng/grpc-web.
We will need to use grpc-web and there needs to be a proxy between every service which convert grpc-web request to grpc. Since this is a distributed system this will be very expensive. Just sharing my thoughts.

grpc/grpc-go#2294
grpc/grpc-go#906

grpc-web and grpc are different

@mallochine
Copy link
Contributor

anyway, if grpc can compile to wasm (despite it not being able to run in browser), we can just use runtime param/flag for this. That is probably easier to do

@shravanshetty1
Copy link
Author

grpc/grpc-go#2294 - states it doesnt compile to wasm (yet)

@mallochine
Copy link
Contributor

OK. So your plan is to create a go file that's dedicated to network/API interfacing with others? Then you're going to have 2 versions of this go file, one for wasm and one for normal golang RPCs?

@shravanshetty1
Copy link
Author

Update on this -
Browser clients will you grpc-web instead of http and servers will have a middleware that parses grpc-web requests

@shravanshetty1
Copy link
Author

related to #85

@shravanshetty1
Copy link
Author

After some research golang doesnt have a decent grpc-web client so we cannot use grpc-web, another option is to generate a http client/server from the open api spec using https://github.com/go-swagger/go-swagger

@kushthedude
Copy link
Contributor

gRPC-web will be a lot more performant than the grpc-gateway. This should be done as gRPC-gateway has a heavy flaw on the performance, give it a go https://github.com/thinhdanggroup/benchmark-grpc-web-gateway , gRPC-gateway is a lot costlier than gRPC-web. Since we already have our services implemented, gRPC-gateway is an easy way out for us but sooner or later we should focus on gRPC-web when we are on mainnet. https://github.com/grpc/grpc-web#proxy-interoperability official grpc library also mentions about the exisiting grpc-web go proxying.

@shravanshetty1
Copy link
Author

@kushthedude

After some research golang doesnt have a decent grpc-web client

If you can find a working golang grpc-web client please go ahead and implement it.

@kushthedude
Copy link
Contributor

After some research golang doesnt have a decent grpc-web client

Isnt that what a reverse proxy is meant to https://github.com/improbable-eng/grpc-web/blob/master/go/grpcwebproxy/ see the following implementation.

@shravanshetty1
Copy link
Author

Yea maybe you could try to embed that in gosdk, could work havent tried it

@moldis moldis closed this as completed Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants