MetalPuppyTheThird
❔ HttpClient does not respect CancellationToken
The client requests to give a car in the response. There are 3 services, one to create the engine, one to create the body, and one to do the electricals. Client gives a 20s timeout to the app. The services, by historical data and agreement, are decided that they will complete their task in 5s each.
Now, one of the service, a shitty service - electricals in this instance, takes 8s or 10s to do it's thing. Don't care why, but it takes that much time. Now I've passed a 5s timeout to that service -- which is not being respected. I create that 5s timeout by using linkedTokenSource.
What is happening currently is, the runtime( whole app ) is >20s since that shitty service is not respecting the token.
When it takes > cancellationToken, eventually it fails with a TaskCancelledException, post that, the application observes the original token is also marked cancelled so it too times out.
28 replies
❔ HttpClient does not respect CancellationToken
apologies, let me elaborate in a simple way.
My use case is : call n services in X time. X is the original cancellationToken.
One of these n services is the one that I have described above. This service has to have it's own cancellationToken which must be < original cancellationToken so as to give other services their own time to run. The tokens that is passed to these services are created by doing a
createLinkedTokenSource(originalToken)
and cancelAfter(time_for_this_particular_service)
28 replies
❔ HttpClient does not respect CancellationToken
yeah but I think that would not solve my problem. The token passed to the HttpClient is X. X must cancel after Y timespan. but it is not.
Would like to point that the linkedTokenSource is needed because this call has to be capped to a certain value. My use case is the original token cannot be passed to this HttpClient call as the call has a different "max run time" setup in the config.
28 replies
❔ HttpClient does not respect CancellationToken
More details on what is desired state -
Ideally : If app X can tell Y to stop processing because X does not care anymore
Not Ideal but can work : X can chop off the call to Y and Y can keep processing the request
28 replies