hackney icon indicating copy to clipboard operation
hackney copied to clipboard

Add retry attempts to Hackney

Open novabyte opened this issue 10 years ago • 12 comments

I can't find support for retry attempts in Hackney. If it's not supported I'd like to propose it as a feature enhancement.

novabyte avatar Feb 10 '15 10:02 novabyte

Retrying should be an application logic (since it depends when you want to do it) which is why it is not supported right now in hackney but an explicit mechanism can be added.

I think a retry mechanisms should handled the following cases:

  • retry on connection error?
  • retry on POST/PUT error (obviously not when streaming) or only on GET (retry function rule?)

Also if the retry is requested the request should check if it's possible before starting anything (eg. when requested for a stream request).

Did I missed anything?

benoitc avatar Feb 25 '15 06:02 benoitc

Hi @benoitc I was thinking of a simple retry strategy like what's in Fusco: https://github.com/esl/fusco/blob/master/src/fusco.erl#L176

novabyte avatar Feb 25 '15 11:02 novabyte

i wll add these feature in the next release.

benoitc avatar Mar 05 '15 12:03 benoitc

@benoitc Thank you sir :smiley:

novabyte avatar Mar 05 '15 12:03 novabyte

Hi @benoitc have you had time to consider this further? Is it still on the roadmap? Let me know if I can help in some way.

novabyte avatar Jun 16 '15 17:06 novabyte

@novabyte yes it's definitely on the roadmap. I expect to release the 2.0.0 on 06/19 with it.

benoitc avatar Jun 16 '15 21:06 benoitc

I think had an issue related to this. Making requests with a difference of 5 seconds I would get {error, closed}, but if I waited 6-7 seconds a new connection would be used and less than 5 seconds the same connection is reused. It would be useful to reconnect/retry in this case.

edgurgel avatar Jun 21 '15 01:06 edgurgel

I am lagging behind my schedule....

@edgurgel mmm not sure to follow. Do you mean that if you're connecting < 5 sec you actually get an {error, closed} error? What is the keepalive of the server?

Anyway the coming new connection pool should address this issue. I expect now to make a release before the end of the month with it now.

benoitc avatar Jun 22 '15 09:06 benoitc

@benoitc , yeah I forgot to add that the server will keep-alive for exactly 5 seconds. I get a {error, closed} when the time between two requests is too close to 5. If it's 4 or 6 it's fine to reestablish the connection or reuse the previous.

edgurgel avatar Jun 22 '15 10:06 edgurgel

I implemented retries in my download code, it's fairly complete (backoff factor + number of retries, or user-defined function), feel free to use it if you want: https://github.com/flupke/hackney_message_bug/blob/master/lib/hackney_message_bug.ex

flupke avatar Sep 16 '15 09:09 flupke

@benoitc Did this feature ever get implemented? It seems it wasn't since the issue is open, but @edgurgel is referring to a bug introduced by it?

In another note, are there plans to include a feature like this?

edevil avatar Oct 18 '16 15:10 edevil

it's not implemented yet :) but any patch doing that is welcome :)

benoitc avatar Oct 18 '16 16:10 benoitc