I've been dealing with this issue for a while now using HTTPClient. My async method with HTTPClient keeps throwing TaskCanceledException every few hours or so.
I've checked with IsCancellationRequested and confirmed the token was cancelled, so it's not a timeout issue.
https://i.imgur.com/QdCPcFk.png
The exception keeps being thrown on the GetAsync method below:
public async Task CheckDodgeOrStart() // checks if game started
{
while (true)
{
try
{
var response = await client.GetAsync(_baseURL + /lol-gameflow/v1/gameflow-phase");
var stringResponse = await response.Content.ReadAsStringAsync();
if (stringResponse.Contains("InProgress") || stringResponse.Contains("Reconnect"))
{
if (bot.isLeader)
{
Form1.Log(_username + ": " + "Game has successfully started..");
}
break;
}
await Task.Delay(1000);
}
catch (TaskCanceledException e)
{
if (!e.CancellationToken.IsCancellationRequested)
Console.WriteLine("Timeout");
}
}
}
Help would be appreciated, thanks.