Make MaxPendingReads configurable on SftpClient#1796
Draft
Make MaxPendingReads configurable on SftpClient#1796
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SFTP downloads of larger files freeze on Android/mobile devices due to the hardcoded
MaxPendingReads = 100inSftpFileStream. Having 100 concurrent in-flight SSH_FXP_READ requests overwhelms the SSH channel receive window on resource-constrained platforms.Changes
MaxPendingReadsproperty toISftpClientandSftpClient(default 100, minimum 1)constinSftpFileStreamwith an instance field passed throughOpen/OpenAsyncSftpClientforward the configured valueUsage
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/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/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/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: