Closed li1234yun closed 1 month ago
Thanks for sharing the details!
The Connect transport from @connectrpc/connect-web
uses the Protobuf JSON format by default (because that's easy to debug in a web browser). buf curl
will send the data in the Protobuf binary format.
It looks like your server tries to decode the JSON request as Protobuf binary, and fails. As a simple fix, you should be able to pass useBinaryFormat: true
to the transport.
If you prefer to send JSON, you have to configure the server to accept it. Are you using grpc-go behind Envoy with the Connect bridge? It translates the Protocol, but it cannot translate the Payload between binary and JSON. But you can configure grpc-go to support JSON, see the example here.
If you prefer to send JSON, you have to configure the server to accept it. Are you using grpc-go behind Envoy with the Connect bridge?
Yes, I use envoy proxy from connectrpc example. The envoy proxies grpc-go backend services as you said, I will try later.
Thank you very much! @timostamm
@timostamm I try as you said.
useBinaryFormat: true
is ok.useBinaryFormat: false
and grpc-go
backend with connect-example code is not ok. The web still receive the error message:{
"message": "grpc: error unmarshalling request: proto:%C2%A0cannot parse invalid wire-format data",
"code": "internal"
}
Thanks for confirming. Looks like it's working as expected, then.
For grpc-go
, don't forget the blank import to register the codec: https://github.com/connectrpc/envoy-demo/blob/93368e549b12099beb1ebfd4176bfb75c3f0fb0b/server.go#L29
If that doesn't change the result, please open an issue in the envoy-demo repository.
Thank you again @timostamm !
I found my problem, because my grpc-backend services proxied by dapr sidecar. Dapr sidecar grpc server doesn't achieve the json codec support.
If I call grpc-go with codec directly, the api call will be ok.
Describe the bug When I use latest connectrpc beta2 package to send api request, I met this error:
package.json dependencies:
As clearly as you can, please tell us what the bug is.
To Reproduce
Environment (please complete the following information):
"2.0.0-beta.2"
"2.0.0-beta.2"
"next": "^14.2.15"
v22.9.0
129.0.6668.101
If your problem is specific to bundling, please also provide the following information:
Additional context
buf curl
sendconnectrpc
request is ok and I capture http2 request package@connectrpc/connect-web
sendconnectrpc
request failed. I capture the http request.