-
Notifications
You must be signed in to change notification settings - Fork 181
Getting gRPC to work from a web browser. #159
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
Comments
It's probably already tought of/discarded, but why not use websockets as the connection and send/receive http2 frames over it? Clearly it won't be as efficient but it may work... |
Could certainly do that though it would increase the complexity in the browser significantly as we'd have to provide the HTTP2 framing layer which most browsers already have. If we sat on top of XHR/WHATWG Fetch we don't get to interact with flow-control which is a double-edged sword |
What do you mean? How does the XHR/WHATWG Fetch relate to http2? Will all the request be internally translated to http1 reqs or http2 streams? |
Fetch will provide an API for HTTP semantics on top of http/1.1 or http/2 depending on what the browser was able to negotiate with the host as the transport. Given that http/2 allows for full-duplex the API needs to be able to express that even if the transport it's bound to does not. |
FYI |
I have a question. |
same question |
Seems like Fetch may support trailers so there is hope we can support in a Fetch-capable browser without protocol modification. Timelines are still an issue |
@nicolasnoble can you please detail why/how this was closed? |
I actually don't mind keeping that one open. All the other issues and pull requests in this repository were stale and outdated since we killed it, and I just mass-closed it since all the others were relocated in appropriate locations. But there's no good location for that one, and that's in fact appropriate for what we want to do here. |
So, in fact, let's try to get the discussion going. I have heard of different ways and suggestions for getting gRPC to work from a browser. Anyone wants to share? |
Thanks @nicolasnoble the ideal is obviously for browsers/fetch to support trailers properly, just wanted to maintain tracking here. |
Yes, that may be ideal, but maybe we can also do a few other things to workaround this, if for a diminished version of gRPC that is doing unary calls only for example. |
AFAICT, the Fetch API has supported trailers for about a month, so the issue is getting browsers to implement the new functionality.
Why not just use grpc-gateway? It can output a Swagger definition which you should be able to use to generate stubs for many languages. I haven't played with it yet, but AFAICT it supports server streaming, which seems like the hard part… Given how closely gRPC is tied to HTTP/2, and assuming unary-only is insufficient (it certainly is for me, otherwise I'd just use REST with protobuf payloads), I only see two options for true gRPC:
Anything else wouldn't really be gRPC, it would be (at best) something which maps well to gRPC. At that point, I don't see a reason not to just use grpc-gateway, though it would be great to have grpc-gateway integrated into the gRPC server instead of proxying requests to it. |
I must admit I get nauseous at the idea of using WebSockets but layering a basic H2 implementation over it and wrapping that up in the Fetch API might present a reasonable path forward. I would NOT want to put termination for that protocol into every GRPC runtime, I would look to put it into a proxy that could de-awful it. I haven't looked at the Dart library but I have looked at molnarg's for Node though I think that's getting swapped out with nghttp2 as we speak. I believe there is already some polyfill for the Fetch API over XHR that could be used to deliver unary & half-duplex streaming though we would still need to address the trailer issue. That seems fairly tractable as there is flag-space in GRPC framing that we could use to indicate a trailers-in-payload model. I've done a prototype for this and it's not overly onerous in the runtimes. |
After I wrote my last comment I also came across prpc, which may be interesting for people coming across this issue… it doesn't seem to be nearly as polished as grpc-gateway, can't generate a Swagger definition, and it's unary-only, but it works even in App Engine's very limited standard environment.
Agreed. Pushing the existing gRPC protocol over HTTP/2 over WebSocket over HTTP/1.1 is definitely a very ugly hack, but the advantage is it doesn't require any modifications to the existing gRPC protocol. It's still "real" gRPC, just over a slightly odd stack (though obviously less strange than some). I think the bigger problem is that it would require an HTTP/2 implementation in (or transpiled to) JavaScript, which is probably a rather large amount of code.
Now I'm a bit unclear about the constraints on this issue. Are we talking about (1) how to get gRPC as-is working in browsers, (2) how to modify gRPC so it would work in modern browsers, or (3) developing something gRPC-like which would work with HTTP/1.1? I thought this was about (1), but wouldn't what you just suggested be (2)? If it would be possible to extend gRPC slightly to allow it to work in current browsers that sounds great, I just didn't realize it was an option. |
Given that this is a (somewhat) temporary problem until browsers catch up, an HTTP/1.1 gRPC proxy using WebSockets would be more straightforward and might therefore be preferable to the extra complexity of HTTP/2 emulation. The gRPC library could fall back to the HTTP/1.1 protocol on old UAs or you could use server-side browser detection to deliver an alternate library. This would be trivially easy if the UA connects using HTTP/2, and would be very light on the client. A proxy could also optionally do JSON ⇔ Protobuf transcoding, using feature-detection on the client to decide this transparently. |
I think you're confusing "Getting gRPC to work from a web browser" with "Getting gRPC to work from HTTP/1.1". HTTP/2 has fairly good browser support, the real issue (IMHO) is that the changes to the Fetch API to support trailers are, as far as I can tell, not available in any current browser. If there is a way to get gRPC working with current Fetch API implementations I'd be happy. Based on what @louiscryan mentioned about the possibility of trailers-in-payload, it seems like that's quite possible with only relatively minor changes on the server side.
Please no. Several reasons this would be terrible come to mind:
I'd greatly prefer a faster, leaner server. For most applications I think it makes a lot more sense to do more work on the client, basically distributing the workload instead of centralizing it on the server. The only time that may not be true is when client-side code is performance-critical, and using JSON instead of protobuf for such code probably isn't a great idea (though we are probably comparing native JSON decoding with JS-based protobuf decoding, so maybe it is). |
You're right, I did confuse the issue, since the other suggestions were around sitting HTTP/2 on top of HTTP/1.1. However, my suggestion remains valid, I think: Instead of emulating HTTP/2, provide an alternate gRPC client library that uses WebSockets as is. Regarding JSON, I wasn't suggesting a different API, but a way to support the same API on older browsers that don't handle binary wire formats well. If you don't care about such old browsers, then this is moot. |
I'm commencing work on a package that will allow clients to call GRPC services from the browser using a Node.JS server as a proxy. So, the client forms a two-way connection to the node server, and then can perform calls through that server as if they were local using a similar api to the GRPC node.js package. |
Has anyone tried using the grpc bridge functionality from Envoy? "This is a simple filter which enables the bridging of an HTTP/1.1 client which does not support response trailers to a compliant gRPC server." https://lyft.github.io/envoy/docs/configuration/http_filters/grpc_http1_bridge_filter.html |
For those folks not on the community call today there was a demo of using On Thu, Oct 20, 2016 at 12:30 PM, Argishti Rostamian <
|
Folks please rview |
What is the status of this? It seems like there is an implementation here: https://github.com./improbable-eng/grpc-web. |
@wenbozhu Can I get an invite? |
@wenbozhu I'd be interested in an invite as well. |
@wenbozhu I'm interested in an invite too. |
@wenbozhu would love an invite too. |
I'd like one also if possible.
El 13 ago. 2017 20:23, "millisecond" <[email protected]> escribió:
… @wenbozhu <https://github.com./wenbozhu> would love an invite too.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#159 (comment)>,
or mute the thread
<https://github.com./notifications/unsubscribe-auth/AAohL9eP5EgyCbGMi_J2JgsJNKpu76uQks5sXz8JgaJpZM4DvZro>
.
|
@wenbozhu hi thanks, but I didn't really see the invitation. Could you send it again? Thanks |
Many folks are going to want invitations. Is there a chance it could be made public instead? I certainly want to use it, even if in pre-beta stage. |
@wenbozhu hey, can you send invite to me too? It very interesting project I think and I'd love to help. |
@wenbozhu would like an invite as well, thanks! |
@wenbozhu Can I get an invite? |
@wenbozhu I'd like an invite as well. We'd use it heavily and deploy it if there's no major problems. |
@wenbozhu same for me, I didn't want to notify everybody but it seems attempts to be noticed didn't work ;) Could you please provide a way to access to the beta here, or juste say it's not possible =) ? So we can all stop to receive pointless notifications. |
@wenbozhu same here please! (everyone else, sorry to get you excited with another pointless invitation :) ) |
@wenbozhu Could you invite me as well? Thank you!!!!! |
@wenbozhu ^^^ Ditto ^^^ |
@wenbozhu Interested in an invite too! Thanks in advance! |
@wenbozhu I'm interested in an invite too. |
Could I get invite to grpc-web as well? |
@wenbozhu would it be possible for me to get an invite too? |
It looks like people are not taking the time to read through the post :-( @weitzj Could you give some indication of a time frame? |
How is this different from https://github.com./improbable-eng/grpc-web ? |
@wenbozhu could I get an invite as well please? |
This might be helpful to you folks. https://github.com./ericbets/danby |
@wenbozhu could I get an invite as well please? |
I believe the beta is now open and published at https://github.com./grpc/grpc-web (not 100% sure it refers to the same code, but I suspect so. Perhaps @wenbozhu can confirm?). |
Yes. Please have all future discussion on https://github.com./grpc/grpc-web |
Relevant discussion on mailing list: https://groups.google.com/d/topic/grpc-io/5Ic8MKgltwY/discussion
The text was updated successfully, but these errors were encountered: