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

Potential connections leak when response body is not consumed #402

Open
kachayev opened this issue Jul 25, 2018 · 3 comments
Open

Potential connections leak when response body is not consumed #402

kachayev opened this issue Jul 25, 2018 · 3 comments

Comments

@kachayev
Copy link
Collaborator

kachayev commented Jul 25, 2018

It's not an Aleph issue specifically... more like a flaw of async event-driven HTTP communication. Unfortunately with practical implications.

Let's assume I'm using HTTP client and

  1. The server responds with the body that exceeds :response-buffer-size

  2. I do not use :body of the response at all (e.g. I just read headers) or failed to read the entire body.

By default read-timeout is not set, so the client will wait until the body consumption is complete "always" (unless server closes the connection, but we cannot rely on that fact at all). Effectively blocking an acquired connection from the pool. Which eventually would lead to the pool being exhausted and application being "stuck".

In the ideal world, we need to ensure that after response processing is done at least on the requirements is met: either :body is fully consumed or underlying connection is closed. As we cannot do the first, I think it makes sense at least to introduce an API to have an option to close connection explicitly manually.

@ztellman
Copy link
Collaborator

Depending on whether :raw-stream? is true, both the Manifold stream and InputStream have "close" methods that can be used to discard the underlying connection. We could create a method that encompasses both, but I'm not sure that offers much value. In either case, I agree this should be explicitly documented.

@kachayev
Copy link
Collaborator Author

kachayev commented Jul 28, 2018

@ztellman I don't see how/where closing InputStream forces the connection to be discarded 🤔

@ztellman
Copy link
Collaborator

It will close the underlying Manifold stream, which should trigger the connection cleanup.

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

No branches or pull requests

2 participants