Closed dmcgillen closed 3 years ago
@dmcgillen Nice find. I was able to reproduce this locally and I have a fix.
To provide some more context, in 3.10.x
, there is an improvement to reduce copying https://github.com/dakrone/clj-http/pull/475. It seems we do not explicitly close the InputStream after reading an object using :transit
.
Previously, this "worked" because the entire InputStream would be consumed into a byte-array and close the connection.
I've created #565 which should fix this in the next 3.10.x
release.
Thanks for the quick response and fix, @rymndhng, much appreciated.
I'm using a socks proxy to debug some issues I've been having with an api call. The code I'm using is (I've replaced the url with my-url):
Looking at the debug logs, I can see that connections are not being released after each call. After a couple of calls, it hangs because there are no free connections.
The logs at which it hangs are (waiting for a new connection):
If I switch to use
:as :json
, I can see from the logs that after each response has been processed I get the following, showing that connections are released:and therefore everything works as expected. I do not get this when using transit+json.
I noticed the json responses were gzip encoded and the transit ones were not so have tried using
:decompress-body false
with json to see if the problem was to do with that, but it still works fine.This behaviour occurs on 3.10.x versions, but not on 3.9.1.
Thanks!