Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.1k views
in .NET FTP by (120 points)
Hello all,

i have a problem with Free edition.
I made a program wich on schedule dows some FTP downloads.
When i start the program it runs fine, and i can do the transfers.
Then if i wait a minute and process the files again i get an exeption.
If i wait 5 mins it works fine but i think that weird because im using .close(true) and disposing the object.
If i quickly quit program and restart i can download within one minute.

  Dim ftpconn As New FTPConnection
        ftpconn.ServerAddress = Host
        ftpconn.ServerPort = 21
        ftpconn.UserName = username
        FTPConnection.LogLevel = EnterpriseDT.Util.Debug.LogLevel.Debug
        FTPConnection.LogFile = "C:\test123.txt"
        ftpconn.Password = Password
        ftpconn.Connect()  <=============================== Sorry, the maximum number of connections (2) for your host are already connected. (code=530)
        ftpconn.DownloadFile(dest, source)
        ftpconn.Close(True)
        ftpconn.Dispose()


The log shows that it has succesfull downloaded 2 instances and had closed the connections.
DEBUG [FTPConnection] 8 okt 2012 17:05:14.899 : Set LocalDirectory='xxxxxxxxxxxxxxxx'
DEBUG [FTPClient] 8 okt 2012 17:05:14.903 : Connecting to xxxxxxxxxxxxxxxx:21
DEBUG [HostNameResolver] 8 okt 2012 17:05:14.906 : Resolving xxxxxxxxxxxxxxxx
DEBUG [HostNameResolver] 8 okt 2012 17:05:14.912 : xxxxxxxxxxxxxxxx resolved to xxxxxxxxxxxxxxxx
INFO [BaseSocket] 8 okt 2012 17:05:14.913 : Connecting to xxxxxxxxxxxxxxxx:21 with timeout 120000 ms
DEBUG [BaseSocket] 8 okt 2012 17:05:14.920 : Successfully connected to xxxxxxxxxxxxxxxx:21
DEBUG [FTPControlSocket] 8 okt 2012 17:05:14.920 : Setting socket timeout=120000
INFO [FTPControlSocket] 8 okt 2012 17:05:14.922 : Command encoding=System.Text.SBCSCodePageEncoding
DEBUG [FTPControlSocket] 8 okt 2012 17:05:14.925 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 8 okt 2012 17:05:14.930 : 220 ProFTPD 1.3.3g Server (freenas.local FTP Server) [::ffff:xxxxxxxxxxxxxxxx]
DEBUG [FTPConnection] 8 okt 2012 17:05:14.932 : Connected to xxxxxxxxxxxxxxxx (instance=0)
DEBUG [FTPControlSocket] 8 okt 2012 17:05:14.936 : ---> USER support
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.479 : 331 Password required for support
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.480 : ---> PASS ********
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.502 : 230-Welcome to FreeNAS FTP Server
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.502 : 230 User support logged in
DEBUG [FTPConnection] 8 okt 2012 17:05:15.502 : Successfully logged in
INFO [FTPConnection] 8 okt 2012 17:05:15.504 : Auto FEAT disabled
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.505 : ---> TYPE I
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.506 : 200 Type set to I
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.507 : ---> PWD
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.509 : 257 "/" is the current directory
DEBUG [FTPConnection] 8 okt 2012 17:05:15.512 : DownloadFile(xxxxxxxxxxxxxxxx\update.txt,/xxxxxxxxxxxxxxxx/update.txt)
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.516 : ---> REST 0
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.519 : 350 Restarting at 0. Send STORE or RETRIEVE to initiate transfer
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.531 : ---> PASV
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.533 : 227 Entering Passive Mode (95,97,120,212,219,208).
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.533 : Server supplied address=xxxxxxxxxxxxxxxx
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.533 : Server supplied port=56272
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.533 : autoPassiveIPSubstitution=True
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.533 : remoteAddr=xxxxxxxxxxxxxxxx
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.533 : Substituting server supplied IP (xxxxxxxxxxxxxxxx) with remote host IP (xxxxxxxxxxxxxxxx)
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.534 : NewPassiveDataSocket(xxxxxxxxxxxxxxxx,56272)
INFO [BaseSocket] 8 okt 2012 17:05:15.534 : Connecting to xxxxxxxxxxxxxxxx:56272 with timeout 120000 ms
DEBUG [BaseSocket] 8 okt 2012 17:05:15.537 : Successfully connected to xxxxxxxxxxxxxxxx:56272
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.537 : Connected
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.539 : ---> RETR /xxxxxxxxxxxxxxxx/update.txt
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.542 : 150 Opening BINARY mode data connection for /xxxxxxxxxxxxxxxx/update.txt (13 bytes)
DEBUG [FTPClient] 8 okt 2012 17:05:15.552 : Transferred 13 bytes from remote host
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.553 : 226 Transfer complete
DEBUG [FTPConnection] 8 okt 2012 17:05:15.556 : Closing connection (instance=0)
DEBUG [FTPFileFactory] 8 okt 2012 17:05:15.557 : Defaulting to Unix parsing
INFO [FTPControlSocket] 8 okt 2012 17:05:15.558 : Killed control socket
DEBUG [FTPConnection] 8 okt 2012 17:05:15.561 : Set LocalDirectory='xxxxxxxxxxxxxxxx'
DEBUG [FTPClient] 8 okt 2012 17:05:15.561 : Connecting to xxxxxxxxxxxxxxxx:21
DEBUG [HostNameResolver] 8 okt 2012 17:05:15.561 : Resolving xxxxxxxxxxxxxxxx
DEBUG [HostNameResolver] 8 okt 2012 17:05:15.561 : xxxxxxxxxxxxxxxx resolved to xxxxxxxxxxxxxxxx
INFO [BaseSocket] 8 okt 2012 17:05:15.561 : Connecting to xxxxxxxxxxxxxxxx:21 with timeout 120000 ms
DEBUG [BaseSocket] 8 okt 2012 17:05:15.563 : Successfully connected to xxxxxxxxxxxxxxxx:21
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.563 : Setting socket timeout=120000
INFO [FTPControlSocket] 8 okt 2012 17:05:15.563 : Command encoding=System.Text.SBCSCodePageEncoding
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.563 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.771 : 220 ProFTPD 1.3.3g Server (freenas.local FTP Server) [::ffff:xxxxxxxxxxxxxxxx]
DEBUG [FTPConnection] 8 okt 2012 17:05:15.772 : Connected to xxxxxxxxxxxxxxxx (instance=1)
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.772 : ---> USER support
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.779 : 331 Password required for support
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.779 : ---> PASS ********
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.796 : 230-Welcome to FreeNAS FTP Server
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.796 : 230 User support logged in
DEBUG [FTPConnection] 8 okt 2012 17:05:15.796 : Successfully logged in
INFO [FTPConnection] 8 okt 2012 17:05:15.796 : Auto FEAT disabled
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.797 : ---> TYPE I
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.799 : 200 Type set to I
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.799 : ---> PWD
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.801 : 257 "/" is the current directory
DEBUG [FTPConnection] 8 okt 2012 17:05:15.801 : DownloadFile(C:\Program Files\Zabbix\xxxxxxxxagentd.exe,/xxxxxxxxxxxxxxxx/bin/xxxxxxxxagentd.exe)
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.801 : ---> REST 0
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.802 : 350 Restarting at 0. Send STORE or RETRIEVE to initiate transfer
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.803 : ---> PASV
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.806 : 227 Entering Passive Mode (xx,xx,xx,xx,230,177).
DEBUG [FTPControlSocket] 8 okt 2012 17:05:15.806 : Server supplied address=xxxxxxxxxxxxxxxx
DEBUG [FTPControlSocket] 8 okt 2012 17:05:

1 Answer

0 votes
by (51.6k points)
Try using Close(false) instead.

Explanation: It looks like the server is not realizing that the client has disconnected. The fact that you can connect after a few minutes indicates that the server has timed out the connection in the meantime and therefore allows you another connection. Close(true) closes the socket without sending the QUIT command first, so if the server releases connection in the processing of that command then it isn't so strange that it doesn't know you've disconnected.

- Hans (EnterpriseDT)

Categories

...