Skip to content

Make MaxPendingReads configurable on SftpClient#1796

Draft
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-sftp-connection-freeze
Draft

Make MaxPendingReads configurable on SftpClient#1796
Copilot wants to merge 3 commits intodevelopfrom
copilot/fix-sftp-connection-freeze

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 8, 2026

SFTP downloads of larger files freeze on Android/mobile devices due to the hardcoded MaxPendingReads = 100 in SftpFileStream. Having 100 concurrent in-flight SSH_FXP_READ requests overwhelms the SSH channel receive window on resource-constrained platforms.

Changes

  • Add MaxPendingReads property to ISftpClient and SftpClient (default 100, minimum 1)
  • Replace hardcoded const in SftpFileStream with an instance field passed through Open/OpenAsync
  • All existing call sites in SftpClient forward the configured value

Usage

var client = new SftpClient(host, username, password);
client.MaxPendingReads = 10; // Reduce for constrained platforms
client.Connect();

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • d38977a820604547b8c8247a50a9dcf4
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net10.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net10.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net10.0/testhost.dll --port 41281 --endpoint 127.0.0.1:041281 --role client --parentprocessid 4546 --telemetryoptedin false (dns block)
  • e8ec94cbed2742b79b6effd6a995b716
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net10.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net10.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net10.0/testhost.dll --port 41281 --endpoint 127.0.0.1:041281 --role client --parentprocessid 4546 --telemetryoptedin false (dns block)
  • invalid
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net10.0/Renci.SshNet.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net10.0/Renci.SshNet.Tests.deps.json /home/REDACTED/work/SSH.NET/SSH.NET/test/Renci.SshNet.Tests/bin/Debug/net10.0/testhost.dll --port 41281 --endpoint 127.0.0.1:041281 --role client --parentprocessid 4546 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 2 commits May 8, 2026 13:44
… freezes on resource-constrained platforms

Add MaxPendingReads property to ISftpClient and SftpClient (default 100 for backward compatibility).
Pass the value through SftpFileStream.Open/OpenAsync instead of using a hardcoded constant.
Users on Android or other constrained platforms can now reduce this value (e.g., to 10) to prevent freezes when downloading larger files.

Agent-Logs-Url: https://github.com/sshnet/SSH.NET/sessions/b4b9b5e6-e214-41a2-9efd-0c2a63f65426

Co-authored-by: WojciechNagorski <17333903+WojciechNagorski@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sshnet/SSH.NET/sessions/b4b9b5e6-e214-41a2-9efd-0c2a63f65426

Co-authored-by: WojciechNagorski <17333903+WojciechNagorski@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix SFTP connection freeze on Android devices Make MaxPendingReads configurable on SftpClient May 8, 2026
Copilot AI requested a review from WojciechNagorski May 8, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SFTP connection freeze on android devices

2 participants