grpc / grpc/grpc-rust

Malformed response for non `Ok` statuses when using `web_tonic` on the server.

Open
#1,666 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## Bug Report
### Version

`tonic 0.11.0`
`tonic_web 0.11.0`
`tonic_web_wasm_client 0.5.1`

### Platform

Linux zb 6.8.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 16 Mar 2024 17:15:35 +0000 x86_64 GNU/Linux

### Description

I switched from using the traefik reverse proxy for the grpc-web translation layer to the `tonic_web` crate by simply adding the `.accept_http1(true)` and `.layer(GrpcWebLayer::new())` calls to the server builder. When I'm using traefik, everything works fine.

Using `tonic_web`, when `Ok` responses are returned, everything works fine. However, when a non `Ok` status is returned (e.g., `Internal` or `NotFound`), I get the following error on the client:

`Error: Status { code: Unknown, message: "malformed response", metadata: MetadataMap { headers: {"content-length": "0", "content-type": "application/grpc-web+proto"} }, source: Some(MalformedResponse) }!`

I am using the unofficial `tonic_web_wasm_client` since I couldn't get the `tonic_web` client working, as the example is outdated, and I couldn't figure out what to use instead of the `hyper::Client` object. Since it is working with the traefik proxy, I'm guessing the issue is in the new translation layer, not the client crate.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.