Skip to content

In .net 5, When timeout happens, HttpClient throws TaskCaneledException. But the innerException is IOException instead of TimeoutException #49116

Discussion options

You must be logged in to vote

OK, got the issue figured out. So this is a .net 5 restriction. The conversion to TimeoutException is at HttpClient level: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs#L586-L591
So capturing this inside a delegating handler can't detect the TimeoutException.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@arisewanggithub
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by arisewanggithub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants