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 #333 Close HTTP connections #334

Conversation

strangepleasures
Copy link
Contributor

No description provided.

val client = createHttpClient()
val response = client(request)

return ResponseWrapper(response, request.uri.toString())
return ResponseWrapper(response, request.uri.toString()).use(mapper)
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't it fix the issue if we just close the response here? I mean

val client = createHttpClient()
val response = client(request)
response.close()
return ResponseWrapper(response, request.uri.toString())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The connection will be closed of course, but I'm afraid that if you try to access the request's body after that, you'll get an exception

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it seems that closing the response doesn't help at this point. The returned response object is a MemoryResponse, so closing it is a no-op. The HTTP connection is probably expected to be closed in CloseableHttpResponse.toHttp4kResponse which consumes the entire payload, but again, that doesn't happen in our AWS setup.

Copy link
Contributor

Choose a reason for hiding this comment

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

@strangepleasures have you checked that the edits you have introduced fix the issue in your AWS setup?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can provide you with pip package if you need

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ApacheClient() without arguments creates a client with a PoolingHttpClientConnectionManager with infinite TTL. Maybe, that's why connections never get closed.

@ileasile ileasile force-pushed the fix_leaking_http_connections branch from 970b399 to 80e9103 Compare September 27, 2021 09:11
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.

2 participants