MetalPuppyTheThird
❔ HttpClient does not respect CancellationToken
App & Deployment Details
Applications X and Y are DotnetCore 6.0 applications.
X runs on K8s and Y on VMs on the cloud.
Context of the problem
I have two applications, X and Y. Y is a dumb app and it's job is to fetch data from various datasources. Y has certain REST styled endpoints. X has a logic to call the said endpoints of application Y. All calls are async and the use case needs the Http Post call to adhere to the cancellationToken.
Problem
The cancellationToken is set in this fashion
and used in the following manner
we also have logging on top of the httpClient call and it looks like so
Observations
1. The CancellationToken value is always set to 20s. From the ElapsedTime that is logged, we observed that the call does not timeout ~20s but in 1/10th of cases is >20s and has no pattern
2. The 20s timeout was changed to 30s and similar behaviour was observed.
3. Found this SO article describing the same problem
Solutions Tried
1. Used the Polly.Timout but still observing the same issue
28 replies