FTP creationTimout error while transfering large files over FTP
FTP creationTimout error while transfering large files over FTP
I'm transferring an updated program to the client through FTP server. The folder has a total size of 250 MB, I'm facing this problem.
"System.Net.WebException: System error. ---> System.Net.InternalException: System error.
at System.Net.PooledStream.PrePush(Object expectedOwner) at System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse) at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage) at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj) at System.Net.CommandStream.Dispose(Boolean disposing) at System.IO.Stream.Close()rn at System.IO.Stream.Dispose() at System.Net.ConnectionPool.Destroy(PooledStream pooledStream) at System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse) at System.Net.FtpWebRequest.AttemptedRecovery(Exception e) at System.Net.FtpWebRequest.SubmitRequest(Boolean async)
--- End of inner exception stack trace ---
at System.Net.FtpWebRequest.GetResponse()
at WMSUpdateManager.FTPManagerClass.getFileSizeOfDir(String filename) in C:UsersUSERsourcereposWMSUpdateManagerWMSUpdateManagerFTPManagerClass.cs:line 472
at WMSUpdateManager.FTPManagerClass.getFileSize(String filename) in C:UsersUSERsourcereposWMSUpdateManagerWMSUpdateManagerFTPManagerClass.cs:line 439 at WMSUpdateManager.FTPManagerClass.DownloadFileSet(String remoteFile, String localFile) in C:UsersUSERsourcereposWMSUpdateManagerWMSUpdateManagerFTPManagerClass.cs:line 118"
I'm also using this block in a recursive function to get the directory size.
FtpWebRequest sizeRequest;
sizeRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + filename);
sizeRequest.Credentials = new NetworkCredential(username, password);
sizeRequest.UsePassive = true;
sizeRequest.KeepAlive = true;
sizeRequest.Method = WebRequestMethods.Ftp.GetFileSize;
sizeRequest.UseBinary = true;
sizeRequest.EnableSsl = false;
sizeRequest.Timeout = -1;
FtpWebResponse respSize = (FtpWebResponse)sizeRequest.GetResponse(); //problem at line 472
size = respSize.ContentLength;
sizeRequest = null;
respSize.Close();
My log file.
How large a file are you sending? <10M,10M+, 20M+
– jdweng
Jun 29 at 15:30
@jdweng the file is 250 MB
– H DA
Jun 29 at 19:09
Does the server limit the size of the transfer? 250MB sound like server may be dropping connection. I would use sniffer and check TCP transport layer for a FIN.
– jdweng
Jun 29 at 19:35
@jdweng no I transferred the file using the filezella client successfully. this code is called within the download operation.within that function I'm not even using this call recursively. the download checks if it's a directory or a file then if file it downloads or if it's a directory it lists the files and calls itself for each one. the exception was catched in the downloading function.
– H DA
Jun 30 at 6:29
1 Answer
1
This looks like the culprit:
System.Net Information: 0 : [7640] FtpControlStream#54444047 - Received response [421 No-transfer-time exceeded. Closing control connection.]
Your FTP server closes your connection after some time, if you do not do any file transfer. "Size" requests likely do not count as "transfers".
What you can do is to force FtpWebRequest
to open new connection, before the server closes the current one.
FtpWebRequest
For example, this will make .NET open new connection every minute:
sizeRequest.ConnectionGroupName = DateTime.Now.ToString("yyyy-MM-dd-HH-mm");
See also:
Thanks a lot! this worked
– H DA
Jun 30 at 7:24
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Show us log file.
– Martin Prikryl
Jun 29 at 15:18