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
NoSuchElementException from cachedHostConnectionPool #103
Comments
Comment by sirthias Using However, for the high-level APIs that are based on connection-pools it doesn't work "on the inside" as you expect it to, because the stream cancellation that is triggered on the user-level response stream and propagates upwards doesn't actually reach the connections in the pool. This is intentional since the connections in the pool are resources that are shared among several pool client streams. Just because you are not interested in the response anymore doesn't mean that someone else who's request might have been scheduled on the same connection (if pipelining is enabled) doesn't expect a response either. |
Comment by cmbaxter @sirthias, I wanted to test things out using the same approach I outlined in the code sample but instead of using a pool, using a single connection via Http().outboundConnection. I set up a dummy service to always wait 10 seconds before responding so that my takeWithin case would always result in a failure. I turned on trace logging at the io.tcp layer and then ran my test. I was expecting to see debug output indicating that the connection was closed immediately after the takeWithin fails (5 seconds), but I did not see this. I only saw it after 10 seconds when the service being called actually responds. Is this just missing logging or was the connection still open? I want the connection to be closed when the timeout is hit so how do I make sure that happens? |
Comment by sirthias @cmbaxter I see. The way I see it is that cancellation of the response (reading) stream might not currently propagate to the request (writing) stream on the client-side of akka-http, because the underlying TCP-layer has no concept for "stop reading" and therefore simply ignores this cancellation rather than propagate it. After all on the TCP-level you might still want to write even after having announced that you won't read anymore. For an HTTP client, however, this doesn't make sense and we should actually propagate cancellation of the response stream over to the request upstream. |
Comment by sirthias Actually, I just checked and we have a test for the this type of cancellation propagation from the response to the request side: https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/test/scala/akka/http/impl/engine/client/ClientCancellationSpec.scala So, @cmbaxter, would you be able to supply us with a small snippet of code (e.g. a gist) demonstrating the problem? |
Comment by cmbaxter @sirthias, I can't say for sure that there is something wrong. I just expected to see in the trace logging that the connection was closed as soon as the timeout condition was hit and I don't. Here is the sample client side code:
And then the simple little route that takes longer than the allowed 5 second timeout:
Here is the log output from the client side:
This is a trivial example because the call does eventually return and the connection does eventually close. But say the call hung and never returned. If I keep opening connections that don't close I will eventually run into issues with open file handles. Let me know what you think. |
Comment by nkvoll I'm slightly confused as to the state of this right now. The linked issue (akka/akka#17346), is closed, but as far as I can see, it's still only available for the server side? I tried fiddling around with the APIs, but I couldn't find a way to handle request timeouts other than to wait for the idle-timeout to kick in, and cancelling the sink doesn't actually close the associated connection, which leaves dangling resources until the idle-timeout is reached. Have I missed out on something obvious and/or what would be the proper issue to subscribe to? |
I'm closing this for now. There seem to be multiple issues discussed in this ticket but it's pretty unclear whether one or all of them are still current. Please reopen new tickets if something similar can be still observed with the latest version. |
Issue by ktoso
Tuesday Jun 23, 2015 at 16:42 GMT
Originally opened as akka/akka#17816
Promoting a question from akka-user here as a ticket as I'm not sure this is what we expect to happen...
Quoting Chris Baxter:
// cc @sirthias @jrudolph
The text was updated successfully, but these errors were encountered: