Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
1.4k views
in .NET FTP by (200 points)
reopened by
Hi,

I have a licensed edtFTPnet/Compact but I am having issues when transferring files in a very slow connection (UploadFile method) because it got stuck forever. I have enabled Log in ExFTPConnection class hoping to find the problem:

INFO [LicenseProperties] 25 Jun 2015 09:31:41.000 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 25 Jun 2015 09:31:41.000 : Production license
INFO [LicenseProperties] 25 Jun 2015 09:31:41.000 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 25 Jun 2015 09:31:41.000 : Production license
DEBUG [ExFTPClient] 25 Jun 2015 09:31:41.000 : Connecting to ***
DEBUG [HostNameResolver] 25 Jun 2015 09:31:41.000 : Resolving ***
DEBUG [HostNameResolver] 25 Jun 2015 09:31:41.000 : *** resolved to ***
DEBUG [ExFTPControlSocket] 25 Jun 2015 09:31:41.000 : Connecting directly to ftp-server ***:21
INFO [BaseSocket] 25 Jun 2015 09:31:41.000 : Connecting to ***:21
DEBUG [FTPControlSocket] 25 Jun 2015 09:31:43.000 : Setting socket timeout=120000
WARN [FTPControlSocket] 25 Jun 2015 09:31:43.000 : Failed to set socket timeout: An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
INFO [FTPControlSocket] 25 Jun 2015 09:31:44.000 : Command encoding=System.Text.CodePageEncoding
DEBUG [ExFTPControlSocket] 25 Jun 2015 09:31:44.000 : Created control-socket: SocksContext=, ProxySettings=NoProxy, RemoteHost=199.217.116.152, controlPort=21, timeout=120000
DEBUG [FTPControlSocket] 25 Jun 2015 09:31:44.000 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 25 Jun 2015 09:31:44.000 : 220-FileZilla Server version 0.9.49 beta
DEBUG [FTPControlSocket] 25 Jun 2015 09:31:44.000 : 220-written by Tim Kosse (tim.kosse@filezilla-project.org)
DEBUG [FTPControlSocket] 25 Jun 2015 09:31:44.000 : 220 Please visit https://filezilla-project.org/

I've got a WARN message on socket timeout (fail to set) almost everytime I use the Connect() method. I am aware that the default socket timeout value in .NET Framework is 0 (infinite), so maybe this explain the issue that I have. Is this correct? Do you guys have any suggestion to bypass the timeout problem in .NET Compact platform?

Thank you.

4 Answers

0 votes
by (162k points)
Unfortunately you can't set a timeout on sockets in CF.

The best option is kill the socket when you find the transfer has stalled - you can do that via the BytesTransferred event - maybe have a timer that expires if BytesTransferred isn't fired after x seconds.
0 votes
by (200 points)
Hi,

I did something like you said by creating a 'watchdog method (thread)', however UploadFile method still got stuck.

I'm using the UploadFile(string localPath, string remotePath) and when the transfer got stalled, I'm calling:

CancelTransfer();
Close(true);

I saw the log and aparently the socket control is killed internally after calling these methods (30 Jun 2015 15:06:18). And after a few minutes, the Transfer appears to be resuming all by itself but I do not called ResumeTransfer() or UploadFile(). I am doing this correctly when trying to kill the socket/stop the UploadFile method? I do not know why the UploadFile method never ends. Please, can you help me?

INFO [LicenseProperties] 30 Jun 2015 14:58:23.000 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 30 Jun 2015 14:58:23.000 : Production license
INFO [LicenseProperties] 30 Jun 2015 14:58:24.000 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 30 Jun 2015 14:58:24.000 : Production license
DEBUG [ExFTPClient] 30 Jun 2015 14:58:24.000 : Connecting to ***:21
DEBUG [HostNameResolver] 30 Jun 2015 14:58:24.000 : Resolving ***
DEBUG [HostNameResolver] 30 Jun 2015 14:58:24.000 : *** resolved to ***
DEBUG [ExFTPControlSocket] 30 Jun 2015 14:58:25.000 : Connecting directly to ftp-server ***:21
INFO [BaseSocket] 30 Jun 2015 14:58:25.000 : Connecting to ***:21
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:27.000 : Setting socket timeout=120000
WARN [FTPControlSocket] 30 Jun 2015 14:58:28.000 : Failed to set socket timeout: An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
INFO [FTPControlSocket] 30 Jun 2015 14:58:28.000 : Command encoding=System.Text.CodePageEncoding
DEBUG [ExFTPControlSocket] 30 Jun 2015 14:58:28.000 : Created control-socket: SocksContext=, ProxySettings=NoProxy, RemoteHost=***, controlPort=21, timeout=120000
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:29.000 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:32.000 : 220-FileZilla Server version 0.9.49 beta
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:32.000 : 220-written by Tim Kosse (tim.kosse@filezilla-project.org)
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:32.000 : 220 Please visit https://filezilla-project.org/
DEBUG [FTPConnection] 30 Jun 2015 14:58:32.000 : Connected to *** (instance=1)
DEBUG [ExFTPConnection] 30 Jun 2015 14:58:32.000 : Starting KeepAlive thread with period 30s
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:32.000 : ---> USER ***
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:33.000 : 331 Password required for ***
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:33.000 : ---> PASS ********
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:34.000 : 230 Logged on
DEBUG [FTPConnection] 30 Jun 2015 14:58:34.000 : Successfully logged in
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:34.000 : ---> FEAT
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:35.000 : 211-Features:
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:35.000 : MDTM
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:35.000 : REST STREAM
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:35.000 : SIZE
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:35.000 : MLST type*;size*;modify*;
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:35.000 : MLSD
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:36.000 : UTF8
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:36.000 : CLNT
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:36.000 : MFMT
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:36.000 : EPSV
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:36.000 : EPRT
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:36.000 : 211 End
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:36.000 : ---> TYPE I
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:37.000 : 200 Type set to I
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:37.000 : ---> PWD
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:41.000 : 257 "/" is current directory.
DEBUG [FTPConnection] 30 Jun 2015 14:58:41.000 : UploadFile(/Storage Card/Alcohol120_1.9.8.7530.rar,/Alcohol120_1.9.8.7530.rar,False)
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:42.000 : ---> PASV
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:43.000 : 227 Entering Passive Mode (***,241,188)
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:43.000 : Server supplied address=***
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:43.000 : Server supplied port=61884
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:43.000 : autoPassiveIPSubstitution=True
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:43.000 : remoteAddr=***
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:43.000 : Substituting server supplied IP (***) with remote host IP (***)
DEBUG [ExFTPControlSocket] 30 Jun 2015 14:58:44.000 : NewPassiveDataSocket(***,61884)
WARN [FTPControlSocket] 30 Jun 2015 14:58:44.000 : Failed to set socket timeout: An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
DEBUG [HostNameResolver] 30 Jun 2015 14:58:44.000 : Resolving ***
DEBUG [HostNameResolver] 30 Jun 2015 14:58:44.000 : *** resolved to ***
DEBUG [ExFTPControlSocket] 30 Jun 2015 14:58:44.000 : Connecting directly to ftp-server ***:61884
INFO [BaseSocket] 30 Jun 2015 14:58:44.000 : Connecting to ***:61884
DEBUG [ExFTPPassiveDataSocket] 30 Jun 2015 14:58:50.000 : Created passive data-socket: ProxyConnector=
WARN [FTPDataSocket] 30 Jun 2015 14:58:50.000 : Failed to set socket timeout: An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:50.000 : ---> STOR /Alcohol120_1.9.8.7530.rar
DEBUG [FTPControlSocket] 30 Jun 2015 14:58:51.000 : 150 Opening data channel for file upload to server of "/Alcohol120_1.9.8.7530.rar"
DEBUG [FTPConnection] 30 Jun 2015 15:06:18.000 : Closing connection (instance=1)
DEBUG [FTPFileFactory] 30 Jun 2015 15:06:18.000 : Defaulting to Unix parsing
INFO [FTPControlSocket] 30 Jun 2015 15:06:19.000 : Killed control socket
DEBUG [ExFTPConnection] 30 Jun 2015 15:06:18.000 : KeepAlive thread finished.
DEBUG [FTPClient] 30 Jun 2015 15:13:08.000 : Closing source stream
ERROR [FTPClient] 30 Jun 2015 15:13:10.000 : Caught exception
ERROR [FTPClient] 30 Jun 2015 15:13:10.000 : System.IO.IOException: Unable to write data to the transport connection.
ERROR [FTPClient] 30 Jun 2015 15:13:10.000 : CAUSED BY - System.Net.Sockets.SocketException: Unable to write data to the transport connection.
ERROR [FTPClient] 30 Jun 2015 15:13:10.000 : SystemException in Put(string,string,bool)
ERROR [FTPClient] 30 Jun 2015 15:13:10.000 : System.IO.IOException: Unable to write data to the transport connection.
ERROR [FTPClient] 30 Jun 2015 15:13:10.000 : CAUSED BY - System.Net.Sockets.SocketException: Unable to write data to the transport connection.
ERROR [FTPClient] 30 Jun 2015 15:13:11.000 : Exception in ValidateTransferOnError())
ERROR [FTPClient] 30 Jun 2015 15:13:11.000 : EnterpriseDT.Net.Ftp.FTPException: The FTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established.
DEBUG [FTPConnection] 30 Jun 2015 15:13:11.000 : GetLastWriteTime(/Alcohol120_1.9.8.7530.rar)
WARN [FTPConnection] 30 Jun 2015 15:13:11.000 : Could not retrieve modified-time of file /Alcohol120_1.9.8.7530.rar - -1 The FTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established.
ERROR [ExFTPConnection] 30 Jun 2015 15:13:17.000 : Transfe
0 votes
by (162k points)
On ExFTPConnection set the property RetryCount to 0. That will stop the transfer retrying after a failure.
0 votes
by (200 points)
Hi.

Thank you, now I managed to get around the timeout issue by closing the connection.

Best regards,
Rafael

Categories

...