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

Long connection eventually hangs #174

Open
cwc opened this issue Sep 12, 2016 · 4 comments
Open

Long connection eventually hangs #174

cwc opened this issue Sep 12, 2016 · 4 comments

Comments

@cwc
Copy link

cwc commented Sep 12, 2016

My use case is the consumption of server-sent events from a "firehose" API endpoint, which is constantly sending data. Ideally, my connection to this endpoint would never be closed.

The behavior I'm seeing is that, after an indeterminate amount of time, the connection hangs/freezes. No data is being received by my async client process, no errors are generated that I can see, and no %HTTPoison.AsyncEnd{} message has been received.

Whatever's happening seems to be related to hackney's recv_timeout option. With the default or a relatively low timeout like 30 seconds, the freeze happens fairly quickly - after a day or two. If I set the value of this option to :infinity, I see an uptime of two weeks or more - yet the freeze still eventually occurs.

Do I just need to set certain options to support my use case? Or is this a bug?

@sabondano
Copy link

I also need to use httpoison in the same manner and now I'm worried about it freezing. Any suggestions?

@edgurgel
Copy link
Owner

I'm not sure this is a hackney problem. It could be the way that the TCP connection is handled and its configuration options.

One approach would be to have some sort of "heartbeat" that if failed you simply restart the connection?

@cwc
Copy link
Author

cwc commented Sep 20, 2016

FWIW I haven't tried using hackney directly for this; haven't been able to find the time.

If it helps, here's the lib I wrote to consume server-sent events: https://github.com/cwc/eventsource_ex

@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 (#161 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

4 participants