grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.45k stars 760 forks source link

Grpc-web not return exactly grpc status always response 2 Incomplete response #1417

Closed KP-story closed 3 weeks ago

KP-story commented 3 months ago

I gen code using a command protoc -I=./src/proto \ --js_out=import_style=commonjs,binary:./src/generated \ --grpc-web_out=import_style=typescript,mode=grpcweb:./src/generated \ $(find ./src/proto -iname "*.proto") When I sent request that was not valid, Grpc web always response 2 incomplete response , even though my response headers contained the 'grpc-status' and 'grpc-message' fields."

Screenshot 2024-03-29 at 23 37 12
sampajano commented 3 months ago

@KP-story Thanks for the report!

Do you mind following this following Typescript example, and check how things are looking different between that and what you have? https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/ts-example/README.md

Without knowing your whole setup, it's hard to know what's wrong. So it would be easier if you compare the wire data against the demo we have.

KP-story commented 3 months ago

@KP-story Thanks for the report!

Do you mind following this following Typescript example, and check how things are looking different between that and what you have? https://github.com/grpc/grpc-web/blob/master/net/grpc/gateway/examples/echo/ts-example/README.md

Without knowing your whole setup, it's hard to know what's wrong. So it would be easier if you compare the wire data against the demo we have.

HI, My backend was written by rust tonic web. I always response null with grpc-status and grpc-message in metadata. Is it valid ?

dnprogramming commented 3 months ago

@KP-story As I see you are using CloudFlare might I recommend checking if you have access to the CloudFlare Dashboard for that website, go to the Network tab, and scroll to the bottom and make sure gRPC is enabled so it knows to proxy the gRPC API connection. https://developers.cloudflare.com/network/grpc-connections/

KP-story commented 3 months ago

@KP-story As I see you are using CloudFlare might I recommend checking if you have access to the CloudFlare Dashboard for that website, go to the Network tab, and scroll to the bottom and make sure gRPC is enabled so it knows to proxy the gRPC API connection. https://developers.cloudflare.com/network/grpc-connections/

Hi, I have just updated the configuration in Cloudflare, but it's still showing an error. I wonder whether the response Content-Length being equal to zero is the cause of the error.

Screenshot 2024-04-01 at 07 55 03 Screenshot 2024-04-01 at 07 55 14
yzc1114 commented 3 weeks ago

@KP-story Same problem. Did you solve it?

KP-story commented 3 weeks ago

Yes, I have just added "grpc-status" and "grpc-messages" to the "Access-Control-Allow-Headers" in the preflight request. Vào 19:42, Th 4, 12 thg 6, 2024 Zichao Yang @.***> đã viết:

@KP-story https://github.com/KP-story Same problem. Did you solve it?

— Reply to this email directly, view it on GitHub https://github.com/grpc/grpc-web/issues/1417#issuecomment-2162911576, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKG3VI34QQLD6QQA5JX7KJTZHA63VAVCNFSM6AAAAABFOUYXCCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRSHEYTCNJXGY . You are receiving this because you were mentioned.Message ID: @.***>

sampajano commented 3 weeks ago

@KP-story Thanks for the update! Glad to hear that the issue is resolved now! 😃

I will close this issue now :)