tmc / grpc-websocket-proxy

A proxy to transparently upgrade grpc-gateway streaming endpoints to use websockets
MIT License
553 stars 72 forks source link

Does not work after upgrading to grpc gateway 1.7. #14

Closed hijamoya closed 5 years ago

hijamoya commented 5 years ago

Works great before upgrading. After upgrading, the client can not receive the streaming response.

hijamoya commented 5 years ago

In grpc gateway 1.7, the pb.gw.go file

dec := marshaler.NewDecoder(req.Body)

change to

    newReader, berr := utilities.IOReaderFactory(req.Body)
    if berr != nil {
        return nil, metadata, berr
    }
    dec := marshaler.NewDecoder(newReader())

makes the response can not be delivered.

Refer: https://github.com/grpc-ecosystem/grpc-gateway/commit/d8ad87ee91e1062c2a6117bda0b5523e9cb949ef#diff-57c67d14e7ad37c6f4d7d77e14daf3d8

johanbrandhorst commented 5 years ago

Hm, is the problem that it's no longer streaming the request body? It tries to read the whole thing? This could potentially be fixed with an *io.Pipe in the grpc-gateway.

The reason this function was introduced was because we needed a way to read the body several times. There may be a way to have both streaming of the body and the ability to read-from-the-start with some experimentation. It might be worth raising a bug in grpc-gateway if you can nail down exactly why this happened (but I suspect it's the ReadAll call blocking the request body).

johanbrandhorst commented 5 years ago

I think we can close this in favor of https://github.com/grpc-ecosystem/grpc-gateway/issues/894.