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

Abort SSL connections on close, rather than waiting for remote EOF. #167

Merged
merged 14 commits into from Nov 25, 2020

Conversation

tomchristie
Copy link
Member

In order to close encode/httpx#825 and encode/httpx#914

Probably needs tests to check that:

  • We have ResourceWarnings prior to this, but don't have any after it.
  • Possibly an integration test making a request to a poor SSL shutdown URL, to show that it doesn't hang on close.

@tomchristie tomchristie added the bug Something isn't working label Aug 25, 2020
@florimondmanca
Copy link
Member

Possibly an integration test making a request to a poor SSL shutdown URL, to show that it doesn't hang on close.

I looked at https://badssl.com to see if they had a public endpoint for this scenario, but it doesn't seem so (only mostly scenarios for certs-related issues).

@agronholm
Copy link
Contributor

All AnyIO backends should do this properly when standard_compatible=False is passed to TLSStream.wrap() (as backends/anyio.py does).

@tomchristie
Copy link
Member Author

@agronholm Grand - good to know. Any pointers on good ways to test our behaviour before/after this fix?

@agronholm
Copy link
Contributor

agronholm commented Oct 6, 2020

If the client SSLSocket is receiving an unexpected EOF, it should raise ssl.SSLEOFError. Does the http server you test against unconditionally abort the connection on close?

Copy link
Member

@cdeler cdeler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we really need to do that.

As an alternative we can introduce a "close" timeout as the "connect" timeout we already have which can be fired as a last resort

Copy link
Member

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Ideally we'd be adding some tests as Tom suggested in PR description, but I'm also happy enough to merge and release and see if anything breaks. :-)

@cdeler
Copy link
Member

cdeler commented Nov 16, 2020

I think, I hit this problem (probably it was exactly this unclosed socket) while I tried to write the test for #235

@tomchristie tomchristie merged commit 6abf663 into master Nov 25, 2020
@tomchristie tomchristie deleted the abort-ssl-connections-on-close branch November 25, 2020 15:38
@lazka
Copy link

lazka commented Jan 30, 2021

I'm hitting some problems potentially caused by this change: encode/httpx#1459

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ResourceWarning: unclosed transport <_SelectorSocketTransport fd=6> (asyncio only)
5 participants