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

Streaming URLs hang HTTPoison #161

Open
mfclarke opened this issue Aug 4, 2016 · 4 comments
Open

Streaming URLs hang HTTPoison #161

mfclarke opened this issue Aug 4, 2016 · 4 comments

Comments

@mfclarke
Copy link

mfclarke commented Aug 4, 2016

Hi,

I'm using HTTPoison to fetch html data from arbitrary URLs. But if a URL points to a stream, HTTPoison never completes the standard HTTPoison.get, and there's no completion timeout I can use (that I know of), since timeout is just for the initial connection and recv_timeout is for the beginning of the response (not the completion of the response).

Is there a way I can detect if a URL points to a stream with no size, rather than a response with a fixed size, so I can skip them? Or failing that, is there an option I can pass that will timeout of the request isn't completed in x seconds?

Thanks!

@edgurgel
Copy link
Owner

edgurgel commented Sep 1, 2016

Could you point me to an example on how to replicate this issue? I suppose we can expose a "cancel_request" as hackney has ways to do this.

@mfclarke
Copy link
Author

mfclarke commented Sep 1, 2016

Sure, you can execute the following:

HTTPoison.get("http://193.34.51.165/917xfm_128", [], [timeout: 2500, recv_timeout: 7000])

Replace the url with any http streaming url, and the result will be the same.

@mfclarke
Copy link
Author

Just a follow up on this old issue @edgurgel, I had a chance to attempt this with stream_to so I could try doing :hackney.close(ref) to abort the fetch if I accidentally hit an endlessly streaming URL.

But unfortunately this leaks HTTPoison processes. They get stuck in transformer/5.

Not sure where to go from here, but any help would be much appreciated!

@Fitblip
Copy link

Fitblip commented Nov 12, 2020

Hey sorry for resurrecting a really old thread, but I ran into this recently with HTTPoison and streaming large files (to download large files).

I found that disabling the hackney pooling (hackney: [pool: false]) seems to resolve my issues:

HTTPoison.get!(
    url, 
    ["Authorization": "Bearer #{token}"], 
    [stream_to: self(), async: :once, hackney: [pool: false]]
)

I'm going to update the other thread with the same (#174 hopefully that's OK).

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

No branches or pull requests

3 participants