aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-10-18 09:25:49 -0500
committerGitHub <noreply@github.com>2022-10-18 09:25:49 -0500
commit6e77cf20e1ca7548bb27922324592517cebf7883 (patch)
tree6594191fa91b1e0b56ec634ff420a71ea7768a51 /src
parent5951ce9feee7cb22cebcca79e829fc32fb29d6c9 (diff)
parentffb48072c5203975543644f99b02c843b0054fd0 (diff)
downloadslskd-6e77cf20e1ca7548bb27922324592517cebf7883.tar.gz
Merge branch 'master' into clear-uploads
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Network/NetworkClient.cs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/slskd/Network/NetworkClient.cs b/src/slskd/Network/NetworkClient.cs
index baaa1250..a231dad2 100644
--- a/src/slskd/Network/NetworkClient.cs
+++ b/src/slskd/Network/NetworkClient.cs
@@ -25,7 +25,6 @@ namespace slskd.Network
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR.Client;
- using Microsoft.Data.Sqlite;
using Serilog;
using slskd.Cryptography;
using slskd.Shares;
@@ -58,7 +57,6 @@ namespace slskd.Network
private string LastOptionsHash { get; set; }
private IOptionsMonitor<Options> OptionsMonitor { get; }
private IHttpClientFactory HttpClientFactory { get; }
- private HttpClient HttpClient { get; set; }
private HubConnection HubConnection { get; set; }
private bool StartRequested { get; set; }
private CancellationTokenSource StartCancellationTokenSource { get; set; }
@@ -146,7 +144,7 @@ namespace slskd.Network
request.Content = content;
Log.Information("Beginning upload of shares");
- var response = await HttpClient.SendAsync(request);
+ var response = await CreateHttpClient().SendAsync(request);
if (!response.IsSuccessStatusCode)
{
@@ -182,7 +180,7 @@ namespace slskd.Network
request.Content = content;
Log.Information("Beginning upload of file {Filename} with ID {Id}", filename, id);
- var response = await HttpClient.SendAsync(request);
+ var response = await CreateHttpClient().SendAsync(request);
if (!response.IsSuccessStatusCode)
{
@@ -271,6 +269,14 @@ namespace slskd.Network
return Task.CompletedTask;
}
+ private HttpClient CreateHttpClient()
+ {
+ var client = new HttpClient();
+ client.Timeout = TimeSpan.FromMilliseconds(int.MaxValue);
+ client.BaseAddress = new(OptionsMonitor.CurrentValue.Network.Controller.Address);
+ return client;
+ }
+
private void Configure(Options options)
{
if (options.Network.OperationMode.ToEnum<NetworkOperationMode>() != NetworkOperationMode.Agent && !options.Flags.DualNetworkMode)
@@ -296,9 +302,6 @@ namespace slskd.Network
// the retry loop around connection to stop.
StartCancellationTokenSource?.Cancel();
- HttpClient = HttpClientFactory.CreateClient();
- HttpClient.BaseAddress = new(options.Network.Controller.Address);
-
HubConnection = new HubConnectionBuilder()
.WithUrl($"{options.Network.Controller.Address}/hub/agents")
.WithAutomaticReconnect(new[]