Coder Social home page Coder Social logo

Comments (12)

LucioFranco avatar LucioFranco commented on June 17, 2024 1

Ok I dug into this and got it working if I change the content type to application/grpc from application/grpc+proto which doesn't make much sense. I will dig in a bit more into this...

from tonic.

LucioFranco avatar LucioFranco commented on June 17, 2024

@Hirevo just for more debugging purposes by chance could you see what the headers are that gcp returns to you?

So I know we don't quite yet support compression but I am curious if we can disable it.

from tonic.

LucioFranco avatar LucioFranco commented on June 17, 2024

And also since you have an interceptor does changing it to this work?

        .intercept_headers(|headers| {
            let token = "some-valid-google-oauth-token";
            let value = format!("Bearer {0}", token);
            let value = HeaderValue::from_str(value.as_str()).unwrap();
            headers.insert("authorization", value);
			headers.insert("grpc-accept-encoding", HeaderValue::from_str("identity").unwrap());
        })

The docs are not clear specifically if this will work but pretty much for now we need to tell their grpc server that we don't accept any compression.

from tonic.

Hirevo avatar Hirevo commented on June 17, 2024

@LucioFranco Yes, here are the response headers that the Go code received for the gRPC call:

metadata.MD{
    "alt-svc":[]string{
        "quic=\":443\"; ma=2592000; v=\"46,43\",h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000"
    },
    "content-disposition":[]string{"attachment"},
    "content-type":[]string{"application/grpc"},
    "date":[]string{"Mon, 28 Oct 2019 21:12:24 GMT"}
}

I have also just tried the additional header you proposed, but the error has not changed, sadly.

Also, I published both the Rust and Go versions of these tests, with the same setup and crate versions that I have:
Rust: https://github.com/Hirevo/rust-gcp-test
Go: https://github.com/Hirevo/go-gcp-test

from tonic.

peter05010402 avatar peter05010402 commented on June 17, 2024

I got the same Err!
image

from tonic.

LucioFranco avatar LucioFranco commented on June 17, 2024

@peter05010402 what version of tonic are you using?

from tonic.

frostRed avatar frostRed commented on June 17, 2024

I also had the same Error when using grpc steram rpc. It doesn't have the error at program startup but occurs at many minutes after. Then I re-connect to the grpc server and the error is gone but many minutes it will come again.

The server side is golang. And I tried tonic 0.2 and 0.3.1, not change anything.

from tonic.

LucioFranco avatar LucioFranco commented on June 17, 2024

@frostRed you are getting the "unexpected compression flag error" after startup? Usually this only happens when you have an incorrectly configured channel. value 60 for this flag isn't even valid iirc.

from tonic.

frostRed avatar frostRed commented on June 17, 2024

No, after startup everything is ok, it only occurs on after running half hour or longer.

from tonic.

LucioFranco avatar LucioFranco commented on June 17, 2024

Not startup for the process but for the connection? If that is still the issue something that can reproduce this or that we can inspect the frames would be very helpful.

from tonic.

xiaochuanyu avatar xiaochuanyu commented on June 17, 2024

I arrived here googling "invalid compression flag: 60" and found out that I get a similar error message if I use the wrong endpoint URL e.g. using pubsub URL for endpoint with firestore client.
Its a stupid mistake while copy pasting from gcp example but error message is a little cryptic.

    const ENDPOINT: &str = "https://pubsub.googleapis.com";  // wrong endpoint
    let token = "some valid token";
    let token_metadata: MetadataValue<_> = format!("Bearer {}", token).parse().unwrap();

    let channel = Channel::from_static(ENDPOINT)
        .connect()
        .await.unwrap();

    let mut client = FirestoreClient::with_interceptor(channel, move |mut req: Request<()>| {
        req.metadata_mut()
            .insert("authorization", token_metadata.clone());
        Ok(req)
    });
    // ...

Response struct I get if I call client.create_document(...):

Status {
code:
  Internal,
  message: "protocol error: received message with invalid compression flag: 60 (valid flags are 0 and 1) while receiving response with status: 404 Not Found",
  metadata: MetadataMap{
    headers: {
      "date": "Sun, 24 Jul 2022 14:57:20 GMT",
      "content-type": "text/html; charset=UTF-8",
      "server": "ESF",
      "content-length": "1605",
      "x-xss-protection": "0",
      "x-frame-options": "SAMEORIGIN",
      "x-content-type-options": "nosniff",
      "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
    }
  },
  source: None
}

from tonic.

LucioFranco avatar LucioFranco commented on June 17, 2024

This is because google's api is talking http3 and not http2. There could be a few reasons but maybe the way alpn is negotated is't working. Not totally sure what they changed and maybe the example doesn't work anymore?

from tonic.

Related Issues (20)

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.