-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Change in proxy config not reflected by in-process restart (http2 keep-alive connection not closed) #809
Comments
For me refreshing did not change anything as far as I remember, I would still encounter a 502, maybe because of the returned status code? |
Ah, seems Firefox is caching the result. |
@alexex |
I've used that signal couple of times and I do not have this issue. I hope its not a browser caching issue. You may want to try |
It seems it is not a browser caching issue. In my test case I setup 2 instances of caddy to be proxied, one listening on port 8081 and another on 8082. curl: the request is sent correctly to 8082 (request in log of 8082) browser: in the same tab, disabling cache & reloading will still send request to 8081. (request in log of 8081) |
Since the issue only occurs with in-process restart, I guess it has something to do with keep-alive connections. |
The reload can take up to 5 seconds (to kill keep-alive connections) -- did you wait 5 seconds before trying again? (FWIW I cannot reproduce as long as I disable my browser cache.) |
So I do not know why exactly but even after a few minutes while curl reliably returns the new proxy on chrome I still get a 502, even when I have the inspector open and disable caching there. While when I try it in an anonymous windows it seems to work. Something very funky seems to be going on here, but I have no idea what it is. |
It seems the issue is only reproducible on http2 enabled servers. (served on https and with browser supporting http2). |
With |
A workaround seems to be using the func (s *Server) Stop() (err error) {
s.Server.SetKeepAlivesEnabled(false)
s.Server.ConnState = func(c net.Conn, cs http.ConnState) {
if cs == http.StateIdle {
c.Close()
}
}
// ...
} Although the browser will fail on the first request when they try to reuse the connection after Caddy restart, the next request will use the updated proxy. |
Well done Sherlock, well done 😄 @tpng |
Good to know; I'm not sure if this is a "hack" or behavior I want to introduce into Caddy at this time, but thank you for finding it out! Will probably reference this in the future. |
@mholt I would actually still consider this a bug or at least an open question: even after a few hours and deleting the cache and everything my chrome still gives me a bad gateway error while if I open the site in anonymous mode it still works fine. Something very weird is going on. |
So far the only way I found to fix this in chrome is to restart it entirely, after which it will work correctly. Not even closing the tab and re-opening it works. The very same applies to Firefox. @tpng will these browsers keep these connections open indefinitely? Is there any way for these users to get the site working again without completely restarting their browsers? |
I think you will have to pass |
Okay, that's very interesting. I had no idea they would take the persistence so serious as to not close them until I close my browser. Well, that is definitely not a good way to treat my users, as they might be stuck on this connection pretty much forever. In that case I do think from a usability perspective on caddy's site, there are two options: either (1) caddy has to update the configuration for this connection so that without closing the connection the right proxy is checked or (2) the connection has to be closed by caddy, which according to the specs you linked would be valid behavior:
Otherwise some users might be stuck with an invalid connection pretty much forever (how often do you restart your browser?). I will use |
The GODEBUG variables are not covered by Go's API compatibility promise. HTTP/2 support was added in Go 1.6. Please report any issues instead of disabling HTTP/2 support: https://golang.org/s/http2bug |
To be honest I do not really know enough about go, caddy and the eventual interdependencies here to report a bug on GO I think. You guys will probably have to decide where exactly this bug is situated and how it is to be solved, I can unfortunately offer only the usability perspective. If I can do anything to help this, please let me know and I will try to help out as much as I can! |
I hope it will get fixed in Go itself. Edit: |
I believe patches or bug fixes can be released between minor releases, for example 1.7.1. It depends how the Go team classifies this behavior. The more of these edge case issues pop up the less inclined I am to want to try to maintain hacks/patches/fixes for them in Caddy rather than fix them at the source (realizing, of course, that browsers are part of the problem sometimes). This maintenance burden is prone to create errors and slow down progress on the rest of the project in the long run. It's hard for me to make a decision on this until I can reproduce it, which I have not yet been able to do with the instructions given. 😞 It seems that others are able to reproduce this, but it's interesting to me that Caddy doesn't force-kill the connection after 5 seconds even with HTTP/2. When you do the reload, does the old Caddy process stay alive indefinitely and leave two running? |
The issue is only reproducible with http2 and in-process restart, accessing with http2 enabled browser. |
Oh, right, I did remember to use in-process restart in my testing, but forgot about that when writing my comment. What you say about connections staying open, but not accepting new ones, makes sense. We do, however, call |
Yes, since |
I just barely noticed that in the linked issue above. 😄 Now that I understand this better, I'm not sure what to do at this point. We could just chalk it up to a bug in Go. I wonder how difficult it would be to submit a CL for this. |
Well it would be great to fix/workaround this, if not alone to avoid what you can already see above: people disabling http2 because of this using go flags that are not officially supported, but I do not want to annoy anyone, so I will stop lobbying this and just note that I aswell disabled http2 for now, hoping that the flag will not be removed until this is fixed. :-) |
|
1. What version of Caddy are you running (
caddy -version
)?master
2. What are you trying to do?
Reload Caddyfile with new proxy setting with USR1 using in-process restart.
3. What is your entire Caddyfile?
Before:
After:
4. How did you run Caddy (give the full command and describe the execution environment)?
caddy
5. What did you expect to see?
After
kill -USR1
on caddy pid, should show error page of Yahoo instead of Google.6. What did you see instead (give full error messages and/or log)?
Still showing error page of Google.
7. How can someone who is starting from scratch reproduce this behavior as minimally as possible?
The text was updated successfully, but these errors were encountered: