From e1a39de7d5e8127a2a3b52ecc5d09bb4961c40e0 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 11 Oct 2025 00:28:41 -0500 Subject: add transfer timeout setting --- config/slskd.example.yml | 1 + docs/config.md | 7 ++++++- src/slskd/Core/Options.cs | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config/slskd.example.yml b/config/slskd.example.yml index ad3c6113..419c0c9f 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -207,6 +207,7 @@ # timeout: # connect: 10000 # inactivity: 15000 +# transfer: 30000 # buffer: # read: 16384 # write: 16384 diff --git a/docs/config.md b/docs/config.md index 10f296f5..5a4d3155 100644 --- a/docs/config.md +++ b/docs/config.md @@ -705,10 +705,14 @@ Higher connect timeout values will help ensure that operations (browse, download Inactivity timeouts help the application determine when a distributed parent connection has stopped sending data and when connections that have delivered search results (and are unlikely to be used further) from remaining open longer than needed. Reducing this timeout can help low spec systems if port exhaustion is a concern but may result in the application "hunting" for a distributed parent connection needlessly. +Transfer connections use their own timeout value; other Soulseek clients regulate transfer speed by controlling how often data is sent (e.g. send full speed for 5 seconds, send nothing for 25 seconds), +and as such transfers can easily time out due to inactivity if using a lower value. This setting must be at least 30 seconds. + | Command-Line | Environment Variable | Description | | --------------------------- | ------------------------------- | ------------------------------------------------ | | `--slsk-connection-timeout` | `SLSKD_SLSK_CONNECTION_TIMEOUT` | The connection timeout value, in milliseconds | | `--slsk-inactivity-timeout` | `SLSKD_SLSK_INACTIVITY_TIMEOUT` | The connection inactivity value, in milliseconds | +| `--slsk-transfer-timeout` | `SLSKD_SLSK_TRANSFER_TIMEOUT` | The transfer connection timeout value, in milliseconds | #### **YAML** ```yaml @@ -716,7 +720,8 @@ soulseek: connection: timeout: connect: 10000 - inactivity: 15000 + inactivity: 15000 + transfer: 30000 ``` ### Buffers diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 352d23e9..38416ca2 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1675,6 +1675,15 @@ namespace slskd [Description("connection inactivity timeout, in milliseconds")] [Range(1000, int.MaxValue)] public int Inactivity { get; init; } = 15000; + + /// + /// Gets the transfer connection timeout, in milliseconds. + /// + [Argument(default, "slsk-transfer-timeout")] + [EnvironmentVariable("SLSK_TRANSFER_TIMEOUT")] + [Description("transfer connection timeout, in milliseconds")] + [Range(30_000, int.MaxValue)] + public int Transfer { get; init; } = 60000; } /// -- cgit v1.2.3 From 165a480f02408d817f93482966aa586057b38d01 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 11 Oct 2025 00:28:54 -0500 Subject: bump Soulseek.NET to 8.4.0 --- src/slskd/slskd.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slskd/slskd.csproj b/src/slskd/slskd.csproj index 7f5c1004..29d362ef 100644 --- a/src/slskd/slskd.csproj +++ b/src/slskd/slskd.csproj @@ -68,7 +68,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive -- cgit v1.2.3 From ef1038be546899752d37482d8ac2c239813c7315 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 11 Oct 2025 00:29:11 -0500 Subject: rename configureSocketAction to match the Soulseek.NET type --- src/slskd/Core/Extensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slskd/Core/Extensions.cs b/src/slskd/Core/Extensions.cs index 65942180..db75cc9c 100644 --- a/src/slskd/Core/Extensions.cs +++ b/src/slskd/Core/Extensions.cs @@ -51,7 +51,7 @@ namespace slskd /// The connection timeout, in milliseconds, for client and peer TCP connections. /// The inactivity timeout, in milliseconds, for peer TCP connections. /// Optional SOCKS 5 proxy configuration options. - /// + /// /// The delegate invoked during instantiation to configure the server Socket instance. /// /// The new instance. @@ -63,14 +63,14 @@ namespace slskd int? connectTimeout = null, int? inactivityTimeout = null, ProxyOptions proxyOptions = null, - Action configureSocketAction = null) => new ConnectionOptions( + Action configureSocket = null) => new ConnectionOptions( readBufferSize: readBufferSize ?? o.ReadBufferSize, writeBufferSize: writeBufferSize ?? o.WriteBufferSize, writeQueueSize: writeQueueSize ?? o.WriteQueueSize, connectTimeout: connectTimeout ?? o.ConnectTimeout, inactivityTimeout: inactivityTimeout ?? o.InactivityTimeout, proxyOptions: proxyOptions ?? o.ProxyOptions, - configureSocket: configureSocketAction ?? o.ConfigureSocket); + configureSocket: configureSocket ?? o.ConfigureSocket); /// /// Creates a new instance of from this instance of . -- cgit v1.2.3 From 4b3a876411b09aa104c40aea094a9dc34e1d23e3 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 11 Oct 2025 00:29:38 -0500 Subject: configure connection timeouts explicitly --- src/slskd/Application.cs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 7754c4ef..98226d4f 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -380,14 +380,18 @@ namespace slskd proxyOptions: proxyOptions); // os-specific keepalive is configured for long-lived connections for the server and distributed parent/children - var serverOptions = connectionOptions.With(configureSocketAction: socket => ConfigureSocketOptions(socket, OptionsAtStartup.Soulseek.Connection)); + var serverOptions = connectionOptions.With( + inactivityTimeout: -1, // don't disconnect due to inactivity + configureSocket: socket => ConfigureSocketKeepaliveOptions(socket, OptionsAtStartup.Soulseek.Connection)); + var distributedOptions = connectionOptions.With( - writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.WriteQueue, // write queue set to keep distributed children from impacting performance - configureSocketAction: socket => ConfigureSocketOptions(socket, OptionsAtStartup.Soulseek.Connection)); + writeQueueSize: OptionsAtStartup.Soulseek.Connection.Buffer.WriteQueue, // write queue set to keep distributed children from impacting performance + configureSocket: socket => ConfigureSocketKeepaliveOptions(socket, OptionsAtStartup.Soulseek.Connection)); var transferOptions = connectionOptions.With( readBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer, - writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer); + writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer, + inactivityTimeout: OptionsAtStartup.Soulseek.Connection.Timeout.Transfer); var patch = new SoulseekClientOptionsPatch( listenIPAddress: IPAddress.Parse(OptionsAtStartup.Soulseek.ListenIpAddress), @@ -497,7 +501,7 @@ namespace slskd return Task.CompletedTask; } - private void ConfigureSocketOptions(Socket socket, Options.SoulseekOptions.ConnectionOptions options) + private void ConfigureSocketKeepaliveOptions(Socket socket, Options.SoulseekOptions.ConnectionOptions options) { /* os-specific keepalive is configured for long-lived connections for the server and distributed parent/children @@ -509,11 +513,6 @@ namespace slskd */ try { - // these are set in Soulseek.NET too, but to be super, super sure, do it again; these options can cause - // I/O loops to hang indefinitely and are suspected to be a cause of 'stuck' transfers - socket.SendTimeout = options.Timeout.Inactivity; - socket.ReceiveTimeout = options.Timeout.Inactivity; - socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); if (OperatingSystem.IsWindows() && OptionsAtStartup.Flags.LegacyWindowsTcpKeepalive) @@ -1398,12 +1397,18 @@ namespace slskd inactivityTimeout: connection.Timeout.Inactivity, proxyOptions: proxyPatch); - serverPatch = connectionPatch.With(configureSocketAction: socket => ConfigureSocketOptions(socket, options: connection)); - distributedPatch = connectionPatch.With(configureSocketAction: socket => ConfigureSocketOptions(socket, options: connection)); + serverPatch = connectionPatch.With( + inactivityTimeout: -1, // don't disconnect due to inactivity + configureSocket: socket => ConfigureSocketKeepaliveOptions(socket, options: connection)); + + distributedPatch = connectionPatch.With( + writeQueueSize: connection.Buffer.WriteQueue, // write queue set to keep distributed children from impacting performance + configureSocket: socket => ConfigureSocketKeepaliveOptions(socket, options: connection)); transferPatch = connectionPatch.With( readBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer, - writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer); + writeBufferSize: OptionsAtStartup.Soulseek.Connection.Buffer.Transfer, + inactivityTimeout: connection.Timeout.Transfer); } var patch = new SoulseekClientOptionsPatch( -- cgit v1.2.3