✅ getting error using http client
private async Task getGameStatus()
{
using (HttpClient client = new HttpClient())
{
try
{
HttpResponseMessage response = await client.GetAsync("https://game-website/activePlayers");
if (response.IsSuccessStatusCode)
{
string responseContent = await response.Content.ReadAsStringAsync();
DateTime currentTime = DateTime.Now;
string dayOfWeek = currentTime.ToString("dddd", CultureInfo.InvariantCulture);
int hour = currentTime.Hour;
if (dayOfWeek == "Friday" && hour >= 17)
{
GameStatus = "Updating";
}
else
{
GameStatus = "Online";
}
}
else
{
GameStatus = "Offline";
}
}
catch
{
GameStatus = "Offline";
}
}
}private async Task getGameStatus()
{
using (HttpClient client = new HttpClient())
{
try
{
HttpResponseMessage response = await client.GetAsync("https://game-website/activePlayers");
if (response.IsSuccessStatusCode)
{
string responseContent = await response.Content.ReadAsStringAsync();
DateTime currentTime = DateTime.Now;
string dayOfWeek = currentTime.ToString("dddd", CultureInfo.InvariantCulture);
int hour = currentTime.Hour;
if (dayOfWeek == "Friday" && hour >= 17)
{
GameStatus = "Updating";
}
else
{
GameStatus = "Online";
}
}
else
{
GameStatus = "Offline";
}
}
catch
{
GameStatus = "Offline";
}
}
}with this im getting this error:
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (timeapi.io:443)
The program '[34060] Blade Guns.exe' has exited with code 4294967295 (0xffffffff).Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (timeapi.io:443)
The program '[34060] Blade Guns.exe' has exited with code 4294967295 (0xffffffff).






