Skip to content
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

Fix keepalive timeout task will not execute to close transport #1192

Conversation

pacoyang
Copy link
Contributor

@pacoyang pacoyang commented Sep 19, 2021

When transport can not kick off the HTTP protocol, the on_response_complete method will not be executed to start a keep-alive timeout task, in this situation if the client-side stream sends EOF, the server-side will not close this transport by timeout task and this TCP connection will keep CLOSE_WAIT status.

Start a TCP connection with telnet can replicate this issue. Expect the connection should be close after the keep-alive is timeout.

telnet 127.0.0.1 8000

Relates to #160. Some applications like Chrome or wrk will start a TCP connection to send empty-bytes at first before start the HTTP protocol TCP connection.

@Kludex
Copy link
Sponsor Member

Kludex commented Jan 25, 2022

You said this on #1332:

The keep-alive timeout task trigger still has issue, when a TCP connection is established and the client does not send any bytes, the server does not close this connection when keep-alive timeout. It can be reproduced by telnet.

You were referring to this PR/the issue the PR solves, right?

@pacoyang
Copy link
Contributor Author

pacoyang commented Jan 28, 2022

You were referring to this PR/the issue the PR solves, right?

@Kludex As #1332 has merged, Not sure this PR is there any conflicts. I will check and submit another PR later.

@pacoyang pacoyang closed this Jan 28, 2022
@pacoyang pacoyang deleted the fix-keepalive-timeout-task-not-execute branch January 28, 2022 18:06
@bevinhex
Copy link

this still exists on 0.23.2

@bevinhex
Copy link

image
image

@bevinhex
Copy link

log_level="trace" shows "HTTP connection made" when telnet connected, but it keeps that way forever, never timeout

@bevinhex
Copy link

tested on both h11, httptools

@bevinhex
Copy link

traced the error to
image

somehow keep alive handler only set when response complete, not when request just received, thus people can connect and keep tcp connection open , do slow loris attack

@bevinhex
Copy link

image
starting timer once connection_made seems to be fixing the issue for me, not sure if I am doing it correctly though, will see

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants