tonic icon indicating copy to clipboard operation
tonic copied to clipboard

web-grpc client (non-WASM) from Rust.

Open ereOn opened this issue 4 years ago • 1 comments

Feature Request

Crates

tonic-web

Motivation

We recently managed to make AWS Lambda gRPC compatible thanks to tonic and tonic-web.

There is however currently no way to call those from pure Rust clients, as they require HTTP2 and the whole thing we did expects gRPC web.

Proposal

Not sure exactly. I'd like to implement that, but I'd really appreciate some guidance as to what is the best way to proceed.

If you agree such a feature is indeed desirable, could you give me a hint on how to implement it?

Thanks!

Alternatives

Not really. Perhaps I missed something.

ereOn avatar Nov 05 '21 21:11 ereOn

Well, I finally managed to implement something that works well.

But, as I suspect - given the lack of reaction until now - there is no real interest in supporting that in tonic-web, I won't bother trying to make it match the current library standards.

Let me know if that ever changes.

ereOn avatar Nov 15 '21 20:11 ereOn

Any information about how you did this?

john-h-k avatar Aug 16 '23 13:08 john-h-k

@john-h-k Our startup was eventually closed but all our code was open-source.

I think you'll find what you are looking for here: https://github.com/legion-labs/legion/blob/main/crates/lgn-online/src/grpc/web/client.rs

Disclaimer: it is probably not the best Rust code around: we had just started learning Rust. Still, it did work. I had to read on a whole of cryptic gRPC documentation.

Our resulting code would wrap a regular HTTP 1.1 endpoint and fake an HTTP2 content (on both the way in and the way out) as to satisfy tonic's requirements.

The main limitation, from what I recall, is that since gRPC/web can't benefit from server pipelining, you can't support streaming requests.

It's been a while since I wrote this so sorry if I can't give out more detailed information. Hopefully that still helps.

ereOn avatar Aug 18 '23 16:08 ereOn

This now exists via https://github.com/hyperium/tonic/pull/1472

LucioFranco avatar Aug 25 '23 17:08 LucioFranco