grpc / grpc-web

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

unary (grpcweb binary) grpc-web over http3 - no response body #1276

Open wojciak opened 1 year ago

wojciak commented 1 year ago

Hi,

I wanted to use h/3 as the transfer protocol, but grpc-web isn't extracting the response body for some reason - normal fetch seems to work.

Did you encounter this sort of issue?

Screenshot 2022-09-09 at 23 19 46
sampajano commented 1 year ago

Thanks for the question.

Do you mind providing some details on how exactly are you specifying http/3 to be used? thanks :)

wojciak commented 1 year ago

Hi,

Sure!

I have an envoy proxy server with a configuration similar to https://baptistout.net/posts/upgrade-envoy-http3/

You can see the request/response headers etc in the below example request

request_headers response_headers
wojciak commented 1 year ago

Hi - I think I can see what the issue is, the response becomes a streaming response on the protocol level, but for an unary request there is no support for partial XMLHttpRequest processing. Using the fetch api here would be much more convenient imho.

Where can I find the grpc-web client (https://www.npmjs.com/package/grpc-web) in an uncompiled/unobscufated form?

I'll try to use grpc-web-text with the streaming interface and report back - but binary streaming would be super nice to have.

wojciak commented 1 year ago

Figured it out - the XHR Request being used, doesn't support streaming (d'oh). 2 solutions are possible:

  1. Either set an explicit "Connection: close" header in your envoy proxy (which defeats the idea of streaming req/resp)
  2. Use grpc-web for everything up to request creation, but use your own wrapper for actually making the request (a nice guide on streaming requests can be found here https://developer.chrome.com/articles/fetch-streaming-requests/)