GithubHelp home page GithubHelp logo

grpc-web-client's Introduction

grpc-web-client

Crates.io Documentation License

A Rust implementation of the gRPC-Web protocol that allows using tonic in browsers via wasm.

Testing

Running the tests requires wasm-pack.

To run the tests, first start the server:

RUST_LOG=info cargo run -p test-server

Then, after the server is built and running, the tests can be run.

wasm-pack test --firefox --chrome --safari --headless test/test-client

Acknowledgments

This package is heavily based on webtonic.

grpc-web-client's People

Contributors

tharvik avatar titanous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

grpc-web-client's Issues

Build fails when requiring TLS

Hello, I have been using your crate (:pray: ) to implement a grpc client and compiling it to wasm.
All works fine with http, but to use https I need to enable tls and tls-roots features on tonic,
but once I do that the build targeting wasm fails.

Here the build logs and the relevant Cargo.toml section:
https://gist.github.com/noandrea/ce571ece948e309c54c4ce5958c3c3c2

the src project is here https://github.com/noandrea/cosmos-cash-credentials/tree/feat/grpc

do you know if it is a way around this?

Doesn't appear to work on tonic 0.7.0

Looks like something changed in tonic 0.7.0 - I get this sort of error now:

38  | pub struct Client {
    | -----------------
    | |
    | doesn't satisfy `<_ as Service<tonic::codegen::http::Request<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, Status>>>>::Response = tonic::codegen::http::Response<_>`
    | doesn't satisfy `_: GrpcService<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, Status>>`
    | doesn't satisfy `_: Service<tonic::codegen::http::Request<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, Status>>>`
    |
    = note: the following trait bounds were not satisfied:
            `grpc_web_client::Client: GrpcService<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, Status>>`
            `<grpc_web_client::Client as Service<tonic::codegen::http::Request<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, Status>>>>::Response = tonic::codegen::http::Response<_>`
            `grpc_web_client::Client: Service<tonic::codegen::http::Request<http_body::combinators::box_body::UnsyncBoxBody<tonic::codegen::Bytes, Status>>>`

Better error treatment

I am trying to catch errors from the server side, I sent a status "unauthenticated" (code 16) with message "ExpiredSignature"

Received error message from grpc-web-client:
status: Unknown, message: "FetchFailed(JsValue(TypeError: Failed to fetch\nTypeError: Failed to fetch))", details: [], metadata: MetadataMap { headers: {} }

response header:

grpc-status: 16
grpc-message: ExpiredSignature
content-length: 0
date: Mon, 09 Aug 2021 12:06:47 GM

The response header is ok, but the error message needs more treatment, perhaps need to catch response headers and put it into the error message

Service trait required?

So as you probably know from hyperium/tonic#645, I am trying to use this well before it's integrated into Tonic! I have tried integrating it into a simple Yew application without success so far. I'm reporting this because maybe it's relevant to your PR.

I get this error when even just writing an async fn for calling a test endpoint, without calling it:

the trait `Service<yew::services::fetch::Request<http_body::combinators::box_body::BoxBody<bytes::bytes::Bytes, Status>>>` is not implemented for `Client`

yew::services::fetch::Request is a re-exported http::Request. But I have no idea what Service is or where it comes from. One person guessed tokio-tower. I tried disabling the services feature of Yew, too. The error still occurs.

Version bump from tonic 0.4 to 0.6.

The code in the repo uses tonic 0.6.2, but the version on crates.io uses 0.4.2.

My project successfully builds and passes tests with:

grpc-web-client = { git = "https://github.com/titanous/grpc-web-client" }

but fails with:

grpc-web-client = "0.1.2"

I think you just need to bump to 0.1.3 and re-release.

"Unexpected compression flag 128" and "Unexpected EOF decoding stream"

On localhost I dont get these errors - but while running my application over the web I am getting tonic error. Have you encountered these errors? will they be fixed by updating to latest version.

These are the tonic errors being printed to console

status: Internal, message: "Unexpected compression flag: 128, while receiving response with status: 200 OK", details: [], metadata: MetadataMap { headers: {} }
status: Internal, message: "Unexpected EOF decoding stream.", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc-web+proto", "date": "Fri, 05 Nov 2021 15:43:00 GMT", "vary": "Origin, Origin", "x-cosmos-block-height": "3151041"} }

Currently using version 0.1.2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.