-
-
Notifications
You must be signed in to change notification settings - Fork 969
Description
I didn't find issue with a useful answer to this comparison.
I'm trying to download files from SFTP Server (the platform i'm building can access multiple SFTP in a generic way).
I'm facing an issue where downloading a 10Mo file using SftpFileStream.OpenAsync with SftpFileStream.CopyToAsync is a nightmare.
To download this kind of file, i have to wait at least 45sec-60sec in average (same behavior using the synchronous CopyTo).
Seems to have an issue in the Read/ReadAsync of the SftpFileStream here.
After looking for a workaround, i found a potential solution was using the synchronous method to download a file.
And, unfortunately, this solution was indeed better (10-15sec for this 10Mo file) which is still low, but i can live with that, i'm not that familar with the protocol, maybe it's part of it.
In my case, where i have a lot of SFTP traffic, using a synchronous download is a bit annoying to be honest.
I can afford to wait 10-15sec (synchronous call), but i would like to use the asynchronous call.
When i'm looking at the implementations of both, it seems that "DownloadFile" tries to download chunk concurrently (with a Semaphore limit to 100) which the ReadAsync clearly don't do. So the async read is sequential and read stream sequentially according to the bufferSize (65536 even if i try to increase it).
Is my understanding good ? If so, why this behavior change between sync and async read ?
Is the issue known ? Is that even an issue ?
PS : I'm using the latest version : 2025.0.0
PS2 : It seems that this behavior is happening on some SFTP Server, not everyones. Let me know what you need on the server specs if it can be useful (i only have what is offers by the discover made by the connection)

