FluentFTP: Timed out trying to read data from the socket stream
FTP Server OS: Uknown
FTP Server Type: drftpd / Unkown
Client Computer OS: Windows / Debian
FluentFTP Version: 50.0.1
Framework: .NET 8
Hello, I have the problem that the Asyc client times out. As soon as it fetches the list of names from the FTP. I can’t explain why and I can’t intercept it either. The program closes / crashes completely afterwards.
If I do the same code with the FTP client that is not Async, everything works fine.
Thanks for any help!
Logs :
[22:25:46 ERR] Error with FTP server: *** System.TimeoutException: Timed out trying to read data from the socket stream! at FluentFTP.FtpSocketStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken token) at FluentFTP.FtpDataStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken token) at FluentFTP.FtpSocketStream.ReadLineAsync(Encoding encoding, CancellationToken token) at FluentFTP.AsyncFtpClient.GetNameListing(String path, CancellationToken token) at FluentFTP.AsyncFtpClient.GetNameListing(String path, CancellationToken token) at FluentFTP.AsyncFtpClient.GetNameListing(String path, CancellationToken token) at FTPDownloader.FtpClientAsync.GetNames(String remotePath, CancellationToken cancellationToken) at FTPDownloader.Watcher.Execute(String host, Int32 port, FtpConfiguration configuration, CancellationToken cancellationToken)
`[22:25:12 INF] Start
# Connect(False)
Status: FluentFTP 50.0.1.0(.NET 6.0) AsyncFtpClient
Status: Connecting to IP #1= ***:***
Status: Waiting for a response
Response: 220 DrFTPD+ 2.0 (+STABLE+) $Revision: 1949 $ http://drftpd.org [739033,851d]
Command: AUTH TLS
Status: Waiting for response to: AUTH TLS
Response: 234 AUTH TLS successful [11ms]
Status: FTPS authentication successful, lib = .NET SslStream, cipher suite = Tls12 (Aes256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 44550, 256) [150ms]
Command: USER ***
Status: Waiting for response to: USER ***
Response: 331 Password required for ***. [23ms]
Command: PASS ***
Status: Waiting for response to: PASS ***
Response: 230-
Response: 230- Welcome to the future of FXP:ing
Response: 230- ___ _____________ ___
Response: 230- / _ \____/ __/_ __/ _ \/ _ \
Response: 230- / // / __/ _/ / / / ___/ // /
Response: 230- /____/_/ /_/ /_/ /_/ /____/
Response: 230- DistRibuted FTP Daemon
Response: 230- http://drftpd.org
Response: 230 *** logged in successfully. [13ms]
Command: PBSZ 0
Status: Waiting for response to: PBSZ 0
Response: 200 Command okay [20ms]
Command: PROT P
Status: Waiting for response to: PROT P
Response: 200 Command okay [19ms]
Command: FEAT
Status: Waiting for response to: FEAT
Response: 211-Extensions supported:
Response: PRET
Response: AUTH SSL
Response: PBSZ
Response: CPSV
Response: SSCN
Response: MLST type*,x.crc32*,size*,modify*,unix.owner*,unix.group*,x.slaves*,x.xfertime*
Response: CLNT
Response: NOOP
Response: 211 End [16ms]
Status: Text encoding: System.Text.ASCIIEncoding+ASCIIEncodingSealed
Command: SYST
Status: Waiting for response to: SYST
Response: 215 UNIX system type. [12ms]
Status: Active ServerHandler is: None
Status: Listing parser set to: Machine
Command: PWD
Status: Waiting for response to: PWD
Response: 257 "/" is current directory [12ms]
# DirectoryExists("TEST1/TEST2")
Command: CWD TEST1/TEST2
Status: Waiting for response to: CWD TEST1/TEST2
Response: 250 Directory changed to /TEST1/TEST2 [862ms]
Command: PWD
Status: Waiting for response to: PWD
Response: 257 "/TEST1/TEST2" is current directory [19ms]
Command: CWD /
Status: Waiting for response to: CWD /
Response: 250 Directory changed to / [12ms]
# GetNameListing("TEST1/TEST2")
Command: TYPE I
Status: Waiting for response to: TYPE I
Response: 200 Command okay [50ms]
# OpenDataStreamAsync("NLST /TEST1/TEST2", 0)
# OpenPassiveDataStreamAsync(PASV, "NLST /TEST1/TEST2", 0)
Command: PRET NLST /TEST1/TEST2
Status: Waiting for response to: PRET NLST /TEST1/TEST2
Response: 200 OK, will use master for upcoming transfer [12ms]
Command: PASV
Status: Waiting for response to: PASV
Response: 227 Entering Passive Mode (194,127,172,166,178,9). [17ms]
Status: Connecting to IP #1= ***:***
Command: NLST /TEST1/TEST2
Status: Waiting for response to: NLST /TEST1/TEST2
Response: 150 File status okay; about to open data connection. [12ms]
Warning: SSL Buffering disabled because of .NET 5.0 and later
Status: FTPS authentication successful, lib = .NET SslStream, cipher suite = Tls12 (Aes256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 44550, 256) [66ms]
+---------------------------------------+
Status: Disposing(async) FtpSocketStream(data connection of AsyncFtpClient)
# CloseDataStream()
Status: Testing connectivity using Socket.Poll()...
# CloseDataStream()
Status: Waiting for response to: NLST /TEST1/TEST2
Status: Waiting for response to: NLST /TEST1/TEST2
Response: 226- [Ul: 264.4GB] [Dl: 1.5PB] [Average speed: 199.0GB]
Response: 226- [Credits: -16.1TB] [Ratio: 1:0.0]
Response: 226 Closing data connection [32,671s]
[22:25:46 ERR] Error with FTP server: ***
System.TimeoutException: Timed out trying to read data from the socket stream!
at FluentFTP.FtpSocketStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken token)
at FluentFTP.FtpDataStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken token)
at FluentFTP.FtpSocketStream.ReadLineAsync(Encoding encoding, CancellationToken token)
at FluentFTP.AsyncFtpClient.GetNameListing(String path, CancellationToken token)
at FluentFTP.AsyncFtpClient.GetNameListing(String path, CancellationToken token)
at FluentFTP.AsyncFtpClient.GetNameListing(String path, CancellationToken token)
at FTPDownloader.FtpClientAsync.GetNames(String remotePath, CancellationToken cancellationToken)
at FTPDownloader.Watcher.Execute(String host, Int32 port, FtpConfiguration configuration, CancellationToken cancellationToken)
# Disconnect()
Status: Disposing(async) FtpSocketStream(control connection of AsyncFtpClient)
Status: AsyncFtpClient incorrectly called Close(sync)
Status: Disposing(sync) FtpSocketStream(control connection of AsyncFtpClient)
Status: Not sending QUIT because the connection has already been closed.
# DisposeAsync()
Status: Disposing(async) AsyncFtpClient
# Connect(False)
Status: FluentFTP 50.0.1.0(.NET 6.0) AsyncFtpClient
Unhandled exception. System.TimeoutException: Timed out trying to read data from the socket stream!
at FluentFTP.FtpSocketStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken token)
at FluentFTP.FtpSocketStream.ReadLineAsync(Encoding encoding, CancellationToken token)
at FluentFTP.Client.BaseClient.BaseFtpClient.FluentFTP.IInternalFtpClient.GetReplyInternal(CancellationToken token, String command, Boolean exhaustNoop, Int32 timeOut, Boolean useSema)
at FluentFTP.Client.BaseClient.BaseFtpClient.FluentFTP.IInternalFtpClient.GetReplyInternal(CancellationToken token, String command)
at FluentFTP.Client.BaseClient.BaseFtpClient.FluentFTP.IInternalFtpClient.CloseDataStreamInternal(FtpDataStream stream, CancellationToken token)
at FluentFTP.Client.BaseClient.BaseFtpClient.FluentFTP.IInternalFtpClient.CloseDataStreamInternal(FtpDataStream stream, CancellationToken token)
at FluentFTP.FtpDataStream.CloseAsync(CancellationToken token)
at FluentFTP.FtpSocketStream.<>c__DisplayClass77_0.<<ReadAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Status: Connecting to IP #1= ***:***
Status: Waiting for a response
Response: 220 DrFTPD 3.2.0 https://github.com/drftpd-ng/drftpd3 [739033,852d]
Command: AUTH TLS
Status: Waiting for response to: AUTH TLS
Response: 234 AUTH TLS successful [44ms]
Status: FTPS authentication successful, lib = .NET SslStream, cipher suite = Tls12 (Aes256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, 44550, 255) [2,683s]
Command: USER ***
Status: Waiting for response to: USER ***`
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 40 (2 by maintainers)
Oh, I’m simply waiting the fixes. I had similar issues. But I just switched to 49.0.2 and my issue was resolved.
So, the actual problem was:
Whenever you directly or indirectly cause a NLST command to be issued AND the directory to be listed is empty, this special server answers with a 550… error message. This is not the only way to “send nothing”. Others do it differently. There is code in FluentFTP to handle either such was, but the “550…” code was broken or never functional.
I will now undertake to get this fix validated, further testing etc., then I will merge it. At some point in time it will then be released into the next NuGet release.
That’s great. Thanks for testing.
Certainly, yes. Perhaps. But let’s go slowly, step by step.
Let’s call the problem I worked on “The NLST 550 problem”, ok?
I fixed it for SYNC only and you tested it. Let me now also fix it for the ASYNC client, adding that to the branch you tested, I’ll tell you when that is ready.
And then you can begin to use that for async and we will go on from there and see what happens, ok? Perhaps it will be ok, perhaps there will be more things to look at. But we are making progress and your logs are now such that I can understand the problems better.
For perhaps easier testing, here are all the settings on the client.
I am going to try somehow to reproduce that part you logged, but I am afraid this may take some time. Please stand by.