I have this piece of code:
using var handler = new WebRequestHandler();
handler.ReadWriteTimeout = 5000;
using var client = new HttpClient(handler);
client.BaseAddress = new Uri(resource.ResourceUrl);
client.Timeout = TimeSpan.FromSeconds(60);
remoteData = await client.GetByteArrayAsync(resource.ResourceUrl);
When I kick off the download (a large file of a few hundred MB), then I disconnect from the network, I expected it to time out (throw an exception) after 5 seconds (i.e. 5000 milliseconds) of receiving no data. However, it’s waiting the full 60 seconds set to HttpClient before throwing this exception.
Am I using this wrongly?