hypercorn icon indicating copy to clipboard operation
hypercorn copied to clipboard

hypercorn abruptly closes client connection in the in the middle of test suite execution

Open ganeshmurthy opened this issue 3 years ago • 2 comments
trafficstars

I open up a connection to a quart http2 server, and send several http2 requests one after another over the same connection. After servicing about 5 or 6 requets, hypercorn seems to be closing the client connection abruptly. This started happening when I upgraded from 0.13.2 to 0.14.0/0.14.1

I looked at the tcp_server.py in 0.14.1 and it looks like if self.reader.at_eof() is true, the code ultimately calls self.writer.close() which seems to close the socket.

I will do more research and post my findings here.

ganeshmurthy avatar Aug 31 '22 18:08 ganeshmurthy

Upon further research and using wireshark to see traffic flow, hypercorn initiates the TCP close. http2 allows for long lived connections, so the reason for hypercorn closing the client connection is not entirely clear. Can someone comment on why this behavior changed from 1.13.2 to 1.14.0 ?

We also do the following in our http2 server

from hypercorn import Config as HConfig

# Hypercorn default config sets a connection idle timeout to 5 seconds. This
# will cause the connection to the server to occasionally drop when running on
# slower systems. We do not need idle connection timeout for CI - disable it.
#
HConfig.keep_alive_timeout = 50000.0 

ganeshmurthy avatar Sep 08 '22 17:09 ganeshmurthy

I am having at minimum a similar problem. Hypercorn is closing connections on certain endpoints, that work in 0.13.2. I haven't had a chance to debug it much, other than to confirm that keep_alive_timeout did not resolve the issue.

jordanbray avatar Oct 06 '22 18:10 jordanbray

If this is still a problem please open a new issue - I'd need a little more information and ideally a minimal reproducible example to fix it though.

pgjones avatar Jun 03 '24 20:06 pgjones