C#C
C#2y ago
21 replies
aquatic stone

HttpClient does automatic retry after recieving 408 (Timeout) error code from server

Problem:
When sending http request through httpclient to server, server intentionally returns 408 timeout error response and I want that response also. But what happens is, it is doing automatic retry after recieving this error code and send same request again after removing auth bearer token resulting in 401 (Unauthorized error).

Note: I am not recieving 408 error response, recieving only 401 error response

What I want:
1. Either it will not do retry again
2. or why it is removing authorization token when retrying (how I can add?)

Findings:
1. 408 is transient error code and httpclient has default retry policy for that
2. Can break the circuit using Polly and custom handlers but not working as expected

Can anyone help?
Was this page helpful?