Fix udp test (#10484)

This commit is contained in:
DHR60
2026-11-01 12:58:58 +00:00
committed by GitHub
parent 9593b289b9
commit 70ab27e436
2 changed files with 17 additions and 8 deletions
+3 -6
View File
@@ -135,16 +135,13 @@ public class UdpTestService
roundTripTime = currentRoundTripTime;
}
}
catch (OperationCanceledException) when (timeoutCts.IsCancellationRequested)
catch (OperationCanceledException) when (ct.IsCancellationRequested)
{
throw;
}
catch
catch (OperationCanceledException)
{
if (attempt == 1 && roundTripTime == TimeSpan.MaxValue)
{
throw;
}
// Timeout, continue to next attempt
}
}
+14 -2
View File
@@ -541,8 +541,20 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
private async Task<int> DoUdpTest(ServerTestItem it,
ConcurrentDictionary<string, byte> completedIds, CancellationToken ct = default)
{
var udpService = UdpTestService.CreateFromTarget(_config?.SpeedTestItem.UdpTestTarget, out var udpTestUrl);
var responseTime = (int)(await udpService.SendUdpRequestAsync(udpTestUrl, it.Port, ct)).TotalMilliseconds;
var responseTime = -1;
try
{
var udpService = UdpTestService.CreateFromTarget(_config?.SpeedTestItem.UdpTestTarget, out var udpTestUrl);
responseTime = (int)(await udpService.SendUdpRequestAsync(udpTestUrl, it.Port, ct)).TotalMilliseconds;
}
catch (OperationCanceledException) when (ct.IsCancellationRequested)
{
throw;
}
catch
{
// Ignore
}
ProfileExManager.Instance.SetTestDelay(it.IndexId, responseTime);
await UpdateFunc(it.IndexId, responseTime.ToString());