Getting 404 from compute
Closed this issue · 1 comments
xaocon commented
I'm not certain if this is a bug in the lib or if I'm doing something wrong but I feel like I followed the example pretty closely.
#![allow(unused_imports)]
use googapis::{
CERTIFICATES,
google::cloud::compute::v1::{
Instance,
ForwardingRule,
GetInstanceRequest,
ListInstancesRequest,
AggregatedListInstancesRequest,
instances_client::InstancesClient,
InstanceAggregatedList,
projects_client::ProjectsClient,
GetProjectRequest
},
};
use gouth::Token;
use tonic::{
metadata::MetadataValue,
transport::{Certificate, Channel, ClientTlsConfig},
Request,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
let token = Token::new()?;
let tls_config = ClientTlsConfig::new()
.ca_certificate(Certificate::from_pem(CERTIFICATES))
.domain_name("compute.googleapis.com");
let channel = Channel::from_static("https://compute.googleapis.com")
.tls_config(tls_config)?
.connect()
.await?;
let mut service = ProjectsClient::with_interceptor(channel, move |mut req: Request<()>| {
let token = &*token.header_value().unwrap();
let meta = MetadataValue::from_str(token).unwrap();
req.metadata_mut().insert("authorization", meta);
Ok(req)
});
let instances = service.get(Request::new(GetProjectRequest {
project: "<project >".into(),
..Default::default()
}))
.await?;
println!("{:#?}", instances);
Ok(())
}
and the response looks like
Error: 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: {"content-type": "text/html; charset=UTF-8", "referrer-policy": "no-referrer", "content-length": "1597", "date": "Sun, 28 Nov 2021 16:14:35 GMT", "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 }
I'm using 0.6
mechiru commented
@xaocon
It is possible that the Google API server side is not accepting gRPC requests.
I checked the code of the golang client and it uses REST. Are there any other official Google SDKs that use gRPC?