sshnet / sshnet/SSH.NET

MAC Error when SftpClient.DownloadFile(UWP)

Open
#1,017 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

Remote Server Information
Remote SSH Server version: SSH-2.0-OpenSSH_7.9
Remote Operating System distribution name and architecture: Linux aarch64
What kind of access do you have?: Full physical and software access
Does Putty/WinSCP work?: yes

Local Machine Information
Operating System: Windows 10 21H2
.NET SDKs versions installed: 2.1.511, 2.1.801, 5.0.400

Project information
What is your target framework and architecture?: x64 UWP
Is your project multi-threaded/complex?:

Source Code
Sample Code:

Sample Code:
var sftp = new SftpClient(MyIp, MyLogin, MyPassword);
sftp.Connect();
var memStream= new MemoryStream();
sftp.DownloadFile($"/opt/myfile.json", memStream);

Exceptions and Stack Trace/Call Stack:

Renci.SshNet.Common.SshConnectionException: MAC error
   at Renci.SshNet.SubsystemSession.WaitOnHandle(WaitHandle waitHandle, Int32 millisecondsTimeout)
   at Renci.SshNet.Sftp.SftpSession.RequestRealPath(String path, Boolean nullOnError)
   at Renci.SshNet.Sftp.SftpSession.GetCanonicalPath(String path)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at RouteLoader2022.Loader.Network.FtpRouteAnalyzer.<>c__DisplayClass0_0.<AnalyzeAsync>b__0() in E:\Repos\RouteLoader2022\RouteLoader2022\Loader\Network\FtpRouteAnalyzer.cs:line 42

File transfer related
Transfer over LAN or Internet?: LAN
File size in bytes: 29876 Bytes
Uploading or Downloading? Downloading
Does remote server have enough space to store the file? Yes
Do you have access to the file being uploaded or downloaded? Yes

Increasingsize of SftpClient.BufferSize doesn't help
When do var readStream = SftpClient.OpenRead and then readStream.Read/ReadByte/ReadAsync same MAC Error exceptions throws

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the x64 UWP case with SftpClient.DownloadFile and compare it with SftpClient.OpenRead using the supplied OpenSSH 7.9 server details. Trace the failure from SftpClient.InternalDownloadFile through SftpSession.GetCanonicalPath and RequestRealPath; done means the MAC error is explained and the affected transfer path works without the exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.