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
Close() and CloseGracefully() feedback; use context.Context #2103
Comments
Also, I just noticed that when I call It seems like a call to the underlying listener's Close() should happen in here, regardless of whether ListenAddr was used? https://sourcegraph.com/github.com/lucas-clemente/quic-go@bcac555574071b6fa6af77468927194c4306b924/-/blob/server.go#L316-318 |
I did some further testing. That actual highlighted segment I linked to above is not the culprit, but a lack of So, is this something that can be added? Just the one line to close the underlying PacketConn? |
This is counterintuitive coming from TCP, but it makes sense for QUIC. With QUIC, you can (and quic-go supports this) run a server and multiple clients on the same underlying UDP "connection". This has a lot of advantages, especially for p2p use cases, and we already use that feature in libp2p. That's why we have the check you highlighted in https://github.com/lucas-clemente/quic-go/blob/master/server.go#L314-L318 Can you close the |
Sorry, I think the highlighted segment I linked to was a bit of a red herring; in other words, mostly (or totally) unrelated to my question. But, I found out that adding If you haven't seen it yet, I describe an issue with this, however, that I think is worth a look: caddyserver/caddy#2727 (comment) -- since the only thing that seems to trigger it is the activation of debug mode.
This kinda blows my mind, but it makes sense... so you mean the PacketConn is deliberately not closed, so that any clients which may also be using it can continue to do so? Hmm 🤔 ...
Do you mean, "after calling Yes, I can... however, there are 2 problems:
We're almooooost there, though! |
To summarize the latest updates on the issue about closing the server:
|
Hi @mholt, I read through caddyserver/caddy#2727 again, but I'm not really sure I understand what the actual problem is at this point. Can you update me on the issue? |
@marten-seemann The most relevant details and instructions are in this comment: caddyserver/caddy#2727 (comment). That comment also has the instructions to reproduce the bug. The latest update at the end of the issue shows that although it once appeared fixed, it actually wasn't, as I was able to reproduce the bug. We work around it by not closing the HTTP/3 server, which seems like a leak. |
Hi @mholt, unfortunately I can't run the example any more. Using the caddy.json you posted, I get the following (running Caddy from the v2 branch):
As you can see, Caddy doesn't even listen on the right port, and doesn't seem to use QUIC at all. What am I doing wrong? |
@marten-seemann I also have a few updates on my end for you... First off, Caddy *is* listening on the correct port -- the log entry you're probably referring to is the address of the admin endpoint config API: As for serving QUIC, Sorry about the confusion. 😅 I forgot that since I wrote that comment, I made HTTP/3 opt-in (not on by default, because of this issue). I've just updated that config snippet with the fix, which is to add:
to the "myserver" object (adjacent to "tls_connection_policies" and "routes" and "listen"). I've also updated the curl command that reloads the config, to force a reload even if the config hasn't changed. Since I've also implemented a workaround since I wrote that post, you'll need to uncomment these lines in Caddy: Then comment these lines, which manually close the HTTP/3 servers' listeners as our workaround: Then perform the instructions again. I can no longer get the "Handshake did not complete in time" error, but as you continue to reload the config using curl a few times, you'll see this new log line:
This means that when calling So, a couple of questions I guess:
Maybe this is good news, if I can just get your feedback / experience to confirm, then maybe we can close this, finally... maybe. |
@mholt Thanks for updating the config files. The first request now goes through successfully. I'm getting the following error when reloading the config:
Is that expected? |
Hmm, no, is your config file in the current directory called caddy.json? If not you need to adjust the -d parameter. |
My bad, I was running Now everything works as expected, no matter if Caddy is closing the
Yes, since QUIC allows you to run server and client on the same |
That's great! Let's assume for now that it's fixed unless we hear of it cropping up again. I've made a commit that enables closing both the servers and the listeners, and put a comment in the code linking to relevant issues in case the bug ever arises again. It'd still be nice to have
Gotcha, I guess that'll make more sense once the H3 client API is finished then. Might be a good idea to document that in the godoc: https://pkg.go.dev/github.com/lucas-clemente/quic-go@v0.14.4/http3?tab=doc#Server.Close (if you think it is relevant, it is in Caddy's case, anyway). Thanks! |
We're looking at graduating HTTP/3 out of "experimental" status in Caddy and enabling it by default soon. Just FYI. :) It might be nice to have a graceful way to close listeners working, but it doesn't need to be a showstopper, so no pressure there. Just wanted to let you know that we're moving on this soon! |
Hi,
I look forward to
CloseGracefully()
being implemented sometime. Not urgent for now though. 😃I also would suggest using context.Context for cancellation/timeout instead of specifying a duration. That's how net/http.Server.Shutdown works, and having API parity would be kind of nice. In my case, Caddy will be shutting down net/http.Servers in conjunction with http3.Servers, so doing it the same way by reusing the same context is appealing.
The text was updated successfully, but these errors were encountered: