Open dbrnz opened 1 month ago
Thanks for that link -- it certainly explains things! I now retry proxy failures (502, 503 and 504 result codes) and all seems to be well with the default 5 second timeouts, although I will try your suggestion of a six second Hypercorn timeout to see if that works instead.
BTW, is there a way to have Hypercorn log when it closed a connection because of a timeout?
We have a
quart
based application server running underhypercorn
that, upon receipt of a POST, runs a time-consuming process (usingmultiprocessing
in a separate thread). The initiating client then polls every second using GET to obtain information about its long running process. All well and good, and everything works as expected in a local network environment.Things though start breaking when the server is deployed behind an Apache proxy, with the client occasionally getting 502 proxy errors. After debugging and tracing things, and comparing with the working local client, it appears that:
localhost
case, a new TCPServer is created for each GET request. This server enters idle wait after reading the request and responding -- the next read finds EOF (because therequests
based client has closed the connection after it received a response), that results in the task group and the server's writer stream closing, cancelling the idle wait, and terminating the server instance.@pgjones does this reasoning make sense? It certainly is consistent with my observations and traces. The workaround for me is to increase the keep-alive timeout to something like 10 minutes.