caddy: grpc-web protocol error
Hi ! This is a follow up of #3997 and #4896
@mholt managed to implement a valid grpc-web back then, but later removed that branch and moved the whole grpc-web thing as a plugin here
I’ve been using that branch until recently, when I discovered it to be removed and some Caddyfile config drifts started to appear between v2.5.2 and v2.6.1.
Afterwards, I bumped that plugin and tried to use it. Now I’m getting the following error:
{PROTOCOL_ERROR; received from peer] after Request.Body was written; define Request.GetBody to avoid this error"}
The full error log:
caddy | {"level":"debug","ts":1663845987.8254776,"logger":"http.handlers.file_server","msg":"opening file","filename":"/app/dist/index.html"}
caddy | {"level":"debug","ts":1663845994.7414405,"logger":"http.handlers.rewrite","msg":"rewrote request","request":{"remote_ip":"172.21.0.1","remote_port":"46144","proto":"HTTP/1.1","method":"POST","host":"localhost","uri":"/gate/greeter.Greeter/SayHello","headers":{"X-Grpc-Web":["1"],"Sec-Fetch-Site":["same-origin"],"Accept-Language":["en-US,en;q=0.9"],"Connection":["keep-alive"],"Content-Length":["44"],"Content-Type":["application/grpc-web-text"],"Origin":["http://localhost"],"Accept-Encoding":["gzip, deflate, br"],"Accept":["application/grpc-web-text"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Fetch-Mode":["cors"],"Referer":["http://localhost/"],"Sec-Ch-Ua":["\"Chromium\";v=\"105\", \"Not)A;Brand\";v=\"8\""],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Sec-Fetch-Dest":["empty"]}},"method":"POST","uri":"/greeter.Greeter/SayHello"}
caddy | {"level":"debug","ts":1663845994.7415793,"logger":"http.handlers.reverse_proxy","msg":"selected upstream","dial":"192.168.1.93:50051","total_upstreams":1}
caddy | {"level":"debug","ts":1663845994.7478976,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"192.168.1.93:50051","duration":0.006246607,"request":{"remote_ip":"172.21.0.1","remote_port":"46144","proto":"HTTP/1.1","method":"POST","host":"localhost","uri":"/greeter.Greeter/SayHello","headers":{"Sec-Ch-Ua-Platform":["\"Linux\""],"Sec-Fetch-Dest":["empty"],"Content-Type":["application/grpc-web-text"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Fetch-Mode":["cors"],"X-Forwarded-For":["172.21.0.1"],"X-Forwarded-Host":["localhost"],"Sec-Ch-Ua":["\"Chromium\";v=\"105\", \"Not)A;Brand\";v=\"8\""],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"],"X-Grpc-Web":["1"],"Sec-Fetch-Site":["same-origin"],"Accept-Encoding":["gzip, deflate, br"],"Accept-Language":["en-US,en;q=0.9"],"Origin":["http://localhost"],"Accept":["application/grpc-web-text"],"Referer":["http://localhost/"],"X-Forwarded-Proto":["http"],"Content-Length":["44"]}},"error":"http2: Transport: cannot retry err [stream error: stream ID 3; PROTOCOL_ERROR; received from peer] after Request.Body was written; define Request.GetBody to avoid this error"}
caddy | {"level":"error","ts":1663845994.7479832,"logger":"http.log.error","msg":"http2: Transport: cannot retry err [stream error: stream ID 3; PROTOCOL_ERROR; received from peer] after Request.Body was written; define Request.GetBody to avoid this error","request":{"remote_ip":"172.21.0.1","remote_port":"46144","proto":"HTTP/1.1","method":"POST","host":"localhost","uri":"/gate/greeter.Greeter/SayHello","headers":{"Accept-Language":["en-US,en;q=0.9"],"X-Grpc-Web":["1"],"Sec-Fetch-Site":["same-origin"],"Content-Type":["application/grpc-web-text"],"Origin":["http://localhost"],"Accept-Encoding":["gzip, deflate, br"],"Connection":["keep-alive"],"Content-Length":["44"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Fetch-Mode":["cors"],"Referer":["http://localhost/"],"Accept":["application/grpc-web-text"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Sec-Fetch-Dest":["empty"],"Sec-Ch-Ua":["\"Chromium\";v=\"105\", \"Not)A;Brand\";v=\"8\""],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"]}},"duration":0.006603225,"status":502,"err_id":"h0e22mwvk","err_trace":"reverseproxy.statusError (reverseproxy.go:1271)"}
I built a debug project to show the issue. It implements both front and a backend and was built with Caddy master v2.6.1.
The project is here
@mholt Could you pls take a look 👀 I also think its a good idea to add this project in your CI pipeline 🙄
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (8 by maintainers)
@tetra12 The tests are fixed now. Go forth and do science!
@mohammed90 Yes, tests are working now, thank you! 👍 . Taking a lead to implement a proper GRPC support for Caddy 😎