Handle context canceled errors + better http proxy error handling #644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes how fabio is handling the HTTP/HTTPS proxy "context canceled" errors that are caused basically by the client side closing the connection before getting any response and wrongly reporting a 502 status code in the logs. This is specially annoying for systems like Nomad that use long polling API endpoints and whenever you navigate in the UI, you are constantly closing the long polled connection and getting the
context canceled
error in the logs.Along with the fix, we are using the HTTP Status Code 499 which is a non standard status code created by Nginx to represent
Client Closed Request
responses.Since Fabio also supports HTTP/2, this also solves misleading logs reporting 502 responses when HTTP/2 is used... The HTTP/2 RFC allows a client to close a request connection when the requested resources are already in cache.
I've tested these changes in our internal QA environment and stderr logging is also improved by using the HTTP Proxy ErrorHandler along with
context canceled
being correctly handled.Closes #264