From bcda8bd602db6c5a6abfafee240d4274dd6bfc1f Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 30 Apr 2022 08:32:26 +0800 Subject: [PATCH] Update subscription timeout is set to 30 seconds --- v2rayN/v2rayN/Base/HttpClientHelper.cs | 7 ++----- v2rayN/v2rayN/Handler/DownloadHandle.cs | 6 +++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/v2rayN/v2rayN/Base/HttpClientHelper.cs b/v2rayN/v2rayN/Base/HttpClientHelper.cs index 7ae914f7..a2405adf 100644 --- a/v2rayN/v2rayN/Base/HttpClientHelper.cs +++ b/v2rayN/v2rayN/Base/HttpClientHelper.cs @@ -56,7 +56,7 @@ namespace v2rayN.Base } return null; } - public async Task GetAsync(HttpClient client, string url) + public async Task GetAsync(HttpClient client, string url, CancellationToken token) { if (string.IsNullOrEmpty(url)) { @@ -64,10 +64,7 @@ namespace v2rayN.Base } try { - var cts = new CancellationTokenSource(); - cts.CancelAfter(5000); - - HttpResponseMessage response = await client.GetAsync(url, cts.Token); + HttpResponseMessage response = await client.GetAsync(url, token); return await response.Content.ReadAsStringAsync(); } catch (Exception ex) diff --git a/v2rayN/v2rayN/Handler/DownloadHandle.cs b/v2rayN/v2rayN/Handler/DownloadHandle.cs index b7fb00d5..19840eee 100644 --- a/v2rayN/v2rayN/Handler/DownloadHandle.cs +++ b/v2rayN/v2rayN/Handler/DownloadHandle.cs @@ -156,7 +156,11 @@ namespace v2rayN.Handler { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Utils.Base64Encode(uri.UserInfo)); } - var result = await HttpClientHelper.GetInstance().GetAsync(client, url); + + var cts = new CancellationTokenSource(); + cts.CancelAfter(1000 * 30); + + var result = await HttpClientHelper.GetInstance().GetAsync(client, url, cts.Token); return result; } catch (Exception ex)