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

Retry transient HTTP Errors #311

Closed
mschfh opened this issue Aug 29, 2023 · 6 comments · Fixed by #470
Closed

Retry transient HTTP Errors #311

mschfh opened this issue Aug 29, 2023 · 6 comments · Fixed by #470
Assignees

Comments

@mschfh
Copy link

mschfh commented Aug 29, 2023

Please (re)implement retries for transient HTTP error codes (502, 503, 504, etc) with sensible defaults

Copy link
Contributor

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

@github-actions github-actions bot added the stale label Nov 27, 2023
@apricote
Copy link
Member

apricote commented Dec 4, 2023

Hey @mschfh,

plainly retrying requests could be a bit dangerous, as we do not have an idempotent API. Actions might be taken twice, if the actual API request arrived at the backend, but then some proxy in the middle fails the request.

Do you know of any SDKs/API Clients which do this?

@apricote apricote added Feature and removed stale labels Dec 4, 2023
@alexandernst
Copy link

Copy link
Contributor

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

@github-actions github-actions bot added the stale label Mar 14, 2024
@alexandernst
Copy link

unstale

@jooola
Copy link
Member

jooola commented May 6, 2024

Until we find out the best approach to solve this, you may use an external library that implement a retry round tripper:

package main

import (
	"net/http"

	"github.com/hashicorp/go-retryablehttp"
	"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

func main() {
	token := "YOUR_API_TOKEN"

	httpClient := &http.Client{}
	httpClient.Transport = &retryablehttp.RoundTripper{}

	hcloud.NewClient(
		hcloud.WithToken(token),
		hcloud.WithHTTPClient(httpClient),
	)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants