Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.5k views
in .NET FTP by (120 points)
Our Goal:
The company I work for uses devices that support a variety of communications that we talk to locally (and possibly remotely in the future.)
We are debating using your tool, another tool, or banging it out ourselves.
Your tool looks like it could save us a lot of time, especially at later stages.
To test your software, we are trying to upload a file to the device over FTP.

So far, we...
    CAN send files programmatically CAN send files remotely via FTP using FileZillaCANNOT send via FTP using EnterpriseDT (yet :D)


We can connect!
But we can't do anything :(
We cannot use ftp.UploadFile(), ftp.UploadStream(), or ftp.UploadByteArray().


Do you have any idea why this is not working?


Respectfully,
J. King





My Code:
Public Sub FTPuploadByteArray(ByVal byteArrayToUpload As Byte(), ByVal nameAndExtensionToSaveAs String)

        Try
            'connect to ftp server
            FTPConnection.LogLevel = EnterpriseDT.Util.Debug.LogLevel.All
            FTPConnection.LogFile = Path.Combine(DEBUG_PATH, "ftp_log.txt")

            Dim ftp As New FTPConnection
            ftp.ServerAddress = "111.222.3.44"                                 'Static IP Address of Device that has FTP server capabilities
            ftp.UserName = "~~~~"
            ftp.Password = "****"
            ftp.Connect()                                                      'Connects Successfully
            ftp.TransferType = FTPTransferType.BINARY

            'upload a file
            ftp.UploadByteArray(byteArrayToUpload, nameAndExtensionToSave)     'Errors in here... we also tried using UploadFile() and UploadStream()

            'close the connection
            ftp.Close()

        Catch ex As Exception
            Debug.Print(ex.ToString() + vbNewLine + ex.StackTrace)
        End Try
    End Sub
#End Region


My VB.net Exception + StackTrace:
at EnterpriseDT.Net.Ftp.FTPClient.PutBinary(Stream srcStream, String remoteFile, Boolean append, Boolean alwaysCloseStreams)    at EnterpriseDT.Net.Ftp.FTPClient.Put(Stream srcStream, String remoteFile, Boolean append)    at EnterpriseDT.Net.Ftp.FTPClient.Put(Byte[] bytes, String remoteFile, Boolean append)    at EnterpriseDT.Net.Ftp.FTPConnection.UploadByteArray(Byte[] bytes, String remoteFile, Boolean append)    at EnterpriseDT.Net.Ftp.FTPConnection.UploadByteArray(Byte[] bytes, String remoteFile)    at my.junk.FTPuploadByteArray(Byte[] byteArrayToUpload, String nameAndExtensionToSave)

Full Log
DEBUG [FTPConnection] 17 May 2012 04:45:22.558 : Set LocalDirectory='C:\my.junk\Debug' DEBUG [FTPClient] 17 May 2012 04:45:22.566 : Connecting to111.222.3.44:21 DEBUG [HostNameResolver] 17 May 2012 04:45:22.590 : Resolving 111.222.3.44 DEBUG [HostNameResolver] 17 May 2012 04:45:22.591 : 111.222.3.44 resolved to 111.222.3.44 INFO [BaseSocket] 17 May 2012 04:45:22.593 : Connecting to 111.222.3.44 with timeout 120000 ms DEBUG [BaseSocket] 17 May 2012 04:45:22.607 : Successfully connected to 111.222.3.44:21 DEBUG [FTPControlSocket] 17 May 2012 04:45:22.608 : Setting socket timeout=120000 INFO [FTPControlSocket] 17 May 2012 04:45:22.610 : Command encoding=System.Text.SBCSCodePageEncoding DEBUG [FTPControlSocket] 17 May 2012 04:45:22.614 : StrictReturnCodes=False DEBUG [FTPControlSocket] 17 May 2012 04:45:22.619 : 220 *Device Server* ready. DEBUG [FTPConnection] 17 May 2012 04:45:22.622 : Connected to 111.222.3.44 (instance=0) DEBUG [FTPControlSocket] 17 May 2012 04:45:22.626 : ---> USER root DEBUG [FTPControlSocket] 17 May 2012 04:45:22.627 : 331 User name ok, need password DEBUG [FTPControlSocket] 17 May 2012 04:45:22.629 : ---> PASS ******** DEBUG [FTPControlSocket] 17 May 2012 04:45:22.629 : 230 User logged in DEBUG [FTPConnection] 17 May 2012 04:45:22.629 : Successfully logged in INFO [FTPConnection] 17 May 2012 04:45:22.631 : Auto FEAT disabled DEBUG [FTPControlSocket] 17 May 2012 04:45:22.631 : ---> TYPE I DEBUG [FTPControlSocket] 17 May 2012 04:45:22.632 : 200 Command OK DEBUG [FTPControlSocket] 17 May 2012 04:45:22.633 : ---> PWD DEBUG [FTPControlSocket] 17 May 2012 04:45:22.633 : 257 "/" DEBUG [FTPControlSocket] 17 May 2012 04:45:22.636 : ---> TYPE I DEBUG [FTPControlSocket] 17 May 2012 04:45:22.636 : 200 Command OK DEBUG [FTPControlSocket] 17 May 2012 04:45:22.646 : ---> PASV DEBUG [FTPControlSocket] 17 May 2012 04:45:22.648 : 227 Entering Passive Mode (111.222.3.44,4,49) DEBUG [FTPControlSocket] 17 May 2012 04:45:22.648 : Server supplied address=111.222.3.44 DEBUG [FTPControlSocket] 17 May 2012 04:45:22.648 : Server supplied port=1073 DEBUG [FTPControlSocket] 17 May 2012 04:45:22.648 : autoPassiveIPSubstitution=True DEBUG [FTPControlSocket] 17 May 2012 04:45:22.648 : remoteAddr=111.222.3.44 DEBUG [FTPControlSocket] 17 May 2012 04:45:22.648 : Substituting server supplied IP (111.222.3.44) with remote host IP (111.222.3.44) DEBUG [FTPControlSocket] 17 May 2012 04:45:22.649 : NewPassiveDataSocket(111.222.3.44,1073) INFO [BaseSocket] 17 May 2012 04:45:22.649 : Connecting to 111.222.3.44:1073 with timeout 120000 ms DEBUG [BaseSocket] 17 May 2012 04:45:22.652 : Successfully connected to 111.222.3.44:1073 DEBUG [FTPControlSocket] 17 May 2012 04:45:22.652 : Connected DEBUG [FTPControlSocket] 17 May 2012 04:45:22.654 : ---> STOR test.bmp DEBUG [FTPControlSocket] 17 May 2012 04:45:22.654 : 451 aborted, can't open file INFO [FTPControlSocket] 17 May 2012 04:45:22.654 : Expected reply codes = [125,150,151,350] (strict=False) ERROR [FTPClient] 17 May 2012 04:45:22.678 : Caught exception aborted, can't open file (code=451) DEBUG [FTPClient] 17 May 2012 04:45:22.678 : Closing source stream ERROR [FTPClient] 17 May 2012 04:45:22.678 : Caught exception ERROR [FTPClient] 17 May 2012 04:45:22.678 : EnterpriseDT.

1 Answer

0 votes
by (51.6k points)
The message, "451 aborted, can't open file", in the log-lines below:
DEBUG [FTPControlSocket] 17 May 2012 04:45:22.654 : ---> STOR test.bmp 
DEBUG [FTPControlSocket] 17 May 2012 04:45:22.654 : 451 aborted, can't open file

is coming from the server and indicates that the server is unable to open a handle for that file. There's no indication why it can't do this. It may be that another process already has a lock on the file or that you don't have permission to create file in that directory (though that would usually give a specific permission error).

Try another file-name or another directory. If you have access to the server then check if another process is locking that file. If not then try restarting the server as it may have an error that results in file-handles not being released. Also check the server logs to see if there is more information on why the file doesn't open.

- Hans (EnterpriseDT)

Categories

...