-
-
Notifications
You must be signed in to change notification settings - Fork 83
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 proxied request #84
Comments
I found a solution by myself after discussing with colleagues. Calling the proxy again from the |
Hmmmm. Glad you found a solution, but retry logic might be interesting to add. |
Sorry for commenting here again after one week, but it looks like I did not test as much as I should.
And the main call in the controller was:
As expected, this Test action is responding with 403 (Forbidden)... but only when the response has body. When the response has no body, the status code in the response is 406 (NotAcceptable). In both cases (with and without body) the 'WithAfterReceive' is reached twice, as expected. This is quite strange, and after I briefly check the code I did not find any reason for this to happen.
Even though I found a way to obtain the desired behavior, I would like to avoid this hack. :) |
How would you feel about a |
@twitchax It sounds great to me. Important (IMO) would be the following acceptance criteria:
Are you thinking about bringing up this feature? Do you have an estimation when it would be ready? |
I think we can do this with Polly. public void ConfigureServices(IServiceCollection services)
{
- services.AddProxies();
+ services.AddRouting();
+ services
+ .AddHttpClient("AspNetCore.Proxy.HttpProxyClient")// due to Helpers.HttpProxyClientName is internel.
+ .AddTransientHttpErrorPolicy(policy => policy
+ .OrResult(response => response.StatusCode == HttpStatusCode.NotFound)
+ .RetryAsync(3));// if response failed or not found then retry 3 times.
} |
@h82258652 Sorry for the delayed response. Maybe it works, but I am struggling with an operation that I need to do between attempts. I need to access the user's claims. I noticed the |
Hi, I am trying to proxy some requests with a different authorization header (bearer token).
Now I would like to retry the request if the response is 401, so that I could use refresh the token first. Also I would like to retry only once. Is there a way to do it?
Note: For now I am defining the proxy on the controller.
The text was updated successfully, but these errors were encountered: