You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Timed out trying to read data from the socket stream! #122
This should be fixed in 29.0.0 and onwards.
But if you still have this issue, please add your post below instead of creating duplicate issues!
Thanks.
I am not able to upload a file to a FTPS site. I keep receiving the following error. If the file exists it will delete the file from the FTP but it will not upload the new file.
{"Timed out trying to read data from the socket stream!"}
Here is the log from Core FTP with a successful file transfer.
Resolving ***...
Connect socket #1488 to ***, port 21...
220-Microsoft FTP Service
220-Microsoft FTP Service
220 Welcome To Solutions. All traffic is monitored and scanned.
AUTH TLS
234 AUTH command ok. Expecting TLS Negotiation.
TLSv1.2, cipher TLSv1/SSLv3 (ECDHE-RSA-AES256-SHA384) - 256 bit
USER ***
331 Password required
PASS **********
230 User logged in.
SYST
215 Windows_NT
Keep alive off...
PWD
257 "/" is current directory.
PBSZ 0
200 PBSZ command successful.
PROT P
200 PROT command successful.
PASV
227 Entering Passive Mode (***,196,23).
LIST
Connect socket #1292 to ***, port 50199...
150 Opening ASCII mode data connection.
TLSv1.2, cipher TLSv1/SSLv3 (ECDHE-RSA-AES256-SHA384) - 256 bit
226 Transfer complete.
Transferred 48 bytes in 0.017 seconds
PWD
257 "/" is current directory.
TYPE A
200 Type set to A.
PASV
227 Entering Passive Mode (***,196,24).
STOR Leads_20170619.csv
Connect socket #1440 to ***, port 50200...
TLSv1.2, cipher TLSv1/SSLv3 (ECDHE-RSA-AES256-SHA384) - 256 bit
150 Opening ASCII mode data connection.
226 Transfer complete.
Leads_20170619.csv - 31967 bytes transferred in 0 seconds
MDTM 20170619124726 Leads_20170619.csv
213 20170619124726
Transfer time: 00:00:01
This is very similar to my issue #124, not only because of the same error message ("Timed out trying to read data from the socket stream!") but also because of ASCII vs Binary mode. In your example of a successful transfer, the type is set to ASCII prior to the upload:
TYPE A
200 Type set to A.
PASV
227 Entering Passive Mode (***,196,24).
STOR Leads_20170619.csv
In your logs of the failed transfer on the other hand, the data mode is set to Binary prior to the transfer:
# OpenWrite("/Test.txt", Binary)
Command: TYPE I
Response: 200 Type set to I.
# GetFileSize("/Test.txt")
Command: SIZE /Test.txt
Response: 550 The system cannot find the file specified.
# OpenPassiveDataStream(PASV, "STOR /Test.txt", 0)
Command: PASV
Response: 227 Entering Passive Mode (00,00,00,00,153,114).
Status: Connecting to ***:39282
Command: STOR /Test.txt
@molekamp Amazing that you two have a similar error and thanks for debugging this use case. I will try to support ASCII transfers for the high level APIs too.
Can you try this beta version, which has new properties (UploadDataType, DownloadDataType) that control usage of the ASCII/Binary mode with the high level API.
changed the title [-]Unable to Upload File to FTP[/-][+]Unable to Upload File to FTP - Timed out trying to read data from the socket stream![/+]on Jan 31, 2019
@fschwengsbier Not sure why intellisense recommends it. By design of the original author, the library first tries EPSV then passive then gives up. Not sure why its not working in your case.
Just a follow up on this - we were using .net core v2 when this issue was occurring, hosted on both Linux and Windows. As an act of desperation, we re-wrote our application targeting .NET Framework 4.7 and this issue does not occur at all.
I do have this error seems like when doing GetListing() using net core v3
Status: Disposing FtpSocketStream...
Warning: FtpClient.Disconnect(): Exception caught and discarded while closing control connection: 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.FtpClient.GetReplyAsync(CancellationToken token)
at FluentFTP.FtpClient.ExecuteAsync(String command, CancellationToken token)
at FluentFTP.FtpClient.DisconnectAsync(CancellationToken token)
Status: Disposing FtpSocketStream...
Both ways works when file data don't start on "220".
If start, first string reads and then when trying to read next string throw exception: "Timed out trying to read data from the socket stream"
Activity
robinrodricks commentedon Jun 15, 2017
Please send full logs in order for us to debug. Read the FAQ on how to print or save logs to a file.
JWcodeDev commentedon Jun 15, 2017
Thanks for the Response.
Here are the logs:
robinrodricks commentedon Jun 15, 2017
When you use FileZilla does it work? Can you do this to verify and also paste the FileZilla logs here so I can compare what it does different?
JWcodeDev commentedon Jun 15, 2017
I actually can't get a directory listing through FileZilla but I can through other FTP Clients.
robinrodricks commentedon Jun 18, 2017
Okay use another client but paste the FTP logs so we can compare with our library.
JWcodeDev commentedon Jun 19, 2017
Here is the log from Core FTP with a successful file transfer.
molekamp commentedon Jun 20, 2017
This is very similar to my issue #124, not only because of the same error message ("Timed out trying to read data from the socket stream!") but also because of ASCII vs Binary mode. In your example of a successful transfer, the type is set to ASCII prior to the upload:
In your logs of the failed transfer on the other hand, the data mode is set to Binary prior to the transfer:
robinrodricks commentedon Jun 21, 2017
@molekamp Amazing that you two have a similar error and thanks for debugging this use case. I will try to support ASCII transfers for the high level APIs too.
robinrodricks commentedon Jun 22, 2017
@JWcodeDev
Can you try this beta version, which has new properties (
UploadDataType,DownloadDataType) that control usage of the ASCII/Binary mode with the high level API.Specifically in your case set both to use ASCII mode and that should mimic the behavior by CoreFTP.
greydmar commentedon Jan 11, 2018
I had same issue here.
With Winscp works normally.
After some hours and retries i've found that change
DataConnectionType = FtpDataConnectionType.EPSV,
the problem vanishes ! :)
The choice the connection type involves examinate some server response messages.
In my case, Server response (Thanks FluentFTP Trace)
Connect()
Status: Connecting to ***********
Response: 220 Bs As Argentina
Response: 220-FileZilla Server 0.9.60 beta
(sensible information)
Response: 220-Si no cuenta con la autorizacion, por favor desconecte su sesion
Response: 220-inmediatamente!
Response: 220-
Command: PASS ***
Response: 230 Logged on
Command: FEAT
Response: 211 End
Response: 211-Features:
Response: MDTM
Response: REST STREAM
Response: SIZE
Response: MLST type*;size*;modify*;
Response: MLSD
Response: AUTH SSL
Response: AUTH TLS
Response: PROT
Response: PBSZ
Response: UTF8
Response: CLNT
Response: MFMT
Response: EPSV
Response: EPRT
Status: Text encoding: System.Text.ASCIIEncoding
Command: SYST
Response: 215 UNIX emulated by FileZilla
Status: Auto-detected UNIX listing parser
fschwengsbier commentedon Jul 25, 2018
Yeah.
DataConnectionType = FtpDataConnectionType.EPSV did the trick.
Now I'm able to upload large files.
The C# intellisense recommends this setting. So why we have to set it?
[-]Unable to Upload File to FTP[/-][+]Unable to Upload File to FTP - Timed out trying to read data from the socket stream![/+]robinrodricks commentedon Jan 31, 2019
@fschwengsbier Not sure why intellisense recommends it. By design of the original author, the library first tries EPSV then passive then gives up. Not sure why its not working in your case.
18 remaining items
fayezm commentedon Aug 19, 2020
Just a follow up on this - we were using .net core v2 when this issue was occurring, hosted on both Linux and Windows. As an act of desperation, we re-wrote our application targeting .NET Framework 4.7 and this issue does not occur at all.
Hidend commentedon Nov 16, 2020
I do have this error seems like when doing GetListing() using net core v3
Status: Disposing FtpSocketStream...
Warning: FtpClient.Disconnect(): Exception caught and discarded while closing control connection: 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.FtpClient.GetReplyAsync(CancellationToken token)
at FluentFTP.FtpClient.ExecuteAsync(String command, CancellationToken token)
at FluentFTP.FtpClient.DisconnectAsync(CancellationToken token)
Status: Disposing FtpSocketStream...
VictorKrs commentedon Feb 9, 2021
Hi,
I have this exception when trying read file from ftp server and file starts with "220" and has few strings.
For example, text in file:
Code:
Tried this way:
And this:
Both ways works when file data don't start on "220".
If start, first string reads and then when trying to read next string throw exception: "Timed out trying to read data from the socket stream"
.Net framework 4.0
FluentFtp version: 33.0.3
parthvnp commentedon Feb 23, 2023
Does this issue still need help? Happy to work on it.
FanDjango commentedon Feb 24, 2023
Closing. Please open separate new issues if you encounter problems.
robinrodricks commentedon Nov 16, 2023
PLEASE OPEN NEW ISSUES IF YOU ENCOUNTER THIS ISSUE.
DO NOT ADD YOUR COMMENT HERE.
WE WILL NOT DEBUG OLDER VERSIONS OF FLUENT FTP. SO ENSURE YOU ARE USING THE LATEST VERSION.