-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http/2 transport failing for gRPC #3236
Comments
Thanks for the sample repository. Do you have a repro without Docker though? I don't have Docker installed (I don't use Linux) also we want to simplify things as much as possible when isolating buggy behavior. Edit: Nevermind. Maybe I can just run the binaries that are described in the Dockerfiles. That should work I guess. |
Go itself had this issue with the trailing header: |
Docker runs just fine on Mac btw. Uses a VM under the hood. IO performance is worse, but it's good enough to do basically everything except performance testing |
@Zetanova K I got the server and of course Caddy up and running with your config. How do I reproduce the isssue though? This works (at least, as I would expect):
Yields caddy logs:
|
test setup is: Its only in h2c mode because the golang helloworld example has no TLS support. I think its only the Hop-Hop header removal of TE header This fix should/maybe solves the problem: |
@Zetanova Caddy already uses that patch: caddy/modules/caddyhttp/reverseproxy/reverseproxy.go Lines 389 to 405 in 8b2dbc5
|
@mholt it should be |
@Zetanova Thanks; both of those "work" though (no error as you've reported) -- but grpcurl's output is:
How can I see the error you're seeing? |
@mholt |
Hmm, same result...
Logs:
Does this error for you? |
@mholt didnt testet it with grpclient I made now a simple golang proxy: To proxy gRPC is working with simple proxy. |
@Zetanova Thanks, but how can the rest of us encounter the same error you are reporting? Can you test it with |
@Zetanova Any update on this? Would love to be able to get the error you're seeing. |
@mholt sry for the delay your requested command:
Server-Log:
modified command with proto file:
Server-Log:
|
@Zetanova Thanks, I can see the error now. I'll look into it. Do you have any ideas where we might be going wrong? |
@Zetanova As you can see, the logs show that trailers are being written:
Do you have any insights as to what is expected, if that's not it? |
@Zetanova I've spent most of the evening trying to figure out what is going on 😓 This minimal program proxies correctly: package main
import (
"crypto/tls"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
)
func main() {
upURL, err := url.Parse("http://localhost:50051")
if err != nil {
log.Fatal(err)
}
rp := httputil.NewSingleHostReverseProxy(upURL)
rp.Transport = &http2.Transport{
AllowHTTP: true,
DialTLS: func(network, addr string, _ *tls.Config) (net.Conn, error) {
return net.Dial(network, addr)
},
}
h2s := &http2.Server{}
handler := h2c.NewHandler(rp, h2s)
log.Println("Proxying at localhost:7777")
http.ListenAndServe("localhost:7777", handler)
} I've been drilling down into the http2 libs and trying to figure out why the server is closing the connection. As far as I can tell, we're doing the exact same thing as the above program. Any chance you can help debug this? For anyone following along at home, I'm on the {
"logging": {
"logs": {
"default": {
"level": "DEBUG"
}
}
},
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":80"
],
"insecure_h2c": true,
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"localhost"
]
}
}
},
"transport": {
"protocol": "http",
"versions": ["h2c"]
},
"upstreams": [
{
"dial": "localhost:50051"
}
]
}
]
}
],
"logs": {}
}
}
}
}
} And then using the demo server above provided by @Zetanova, and this command:
|
Hold the phone. Disabling access/request logging (removing |
@mholt It is working now with logging and the original golang gRPC sample client/server |
@Zetanova Excellent! Is there anything else remaining then? |
@mholt The h2, h2c (tcp, uds) + gRPC support looks ok. |
Great - thank you for your help! |
* reverse_proxy: Initial attempt at H2C transport/client support (#3218) I have not tested this yet * Experimentally enabling H2C server support (closes #3227) See also #3218 I have not tested this * reverseproxy: Clean up H2C transport a bit * caddyhttp: Update godoc for h2c server; clarify experimental status * caddyhttp: Fix trailers when recording responses (fixes #3236) * caddyhttp: Tweak h2c config settings and docs
caddy2 is currently not handling the http/2 protocol well.
and this results that gRPC responses are not working.
the issue is that caddy is expecting a regular http1 response,
but a http/2 stream response is not handled at all.
Info on the gRPC protocol
caddy should handle every http/2-request and http/2-responses
as a unique http2-stream and proxy all frames to the same server and/or client
until STREAM_END is received.
I made a simple demo project to reproduce the behavior:
https://github.com/Zetanova/caddy-grpc-demo
Log output:
The text was updated successfully, but these errors were encountered: