Archived Forum Post

Index of archived forum posts


SFTP CloseHandle error code 4 after WriteFileBytes

Dec 17 '15 at 15:45

We have a situation where SFTP files are failing randomly throughout the day about 50% of the time on one of our SFTP connections. Not all connections, just one in particular, and it's seemingly random if it will pass/fail.

Here's the code that we are calling:

// Upload file
if (!sftp.WriteFileBytes(handle, binaryContent)) throw new Exception(sftp.LastErrorText);
// Close the file
if (!sftp.CloseHandle(handle)) throw new Exception(sftp.LastErrorText);

Chilkat is throwing an exception on the CloseHandle function, with error text shown below:

Exception: ChilkatLog:
    DllDate: Oct 29 2015
    UnlockPrefix: [REMOVED FOR PRIVACY]
    Username: [REMOVED FOR PRIVACY]:ASP.NET v4.0
    Architecture: Little Endian; 64-bit
    Language: .NET 4.5 / x64
    VerboseLogging: 0
    SshVersion: SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.7
    SftpVersion: 3
    handle: 00000000
      handle: 00000000
      Sent FXP_CLOSE
        mType: CHANNEL_DATA
        Request: FXP_CLOSE
          StatusCode: 4
          StatusMessage: Failure
      Received a failed status response.

Any insight would be appreciated!

Thanks, Greg


Does this server that fails have a really old version of SSH?


The technical resource on their end "cleaned up the folder", so I assume it was an issue stemming from a large amount of files in the FTP drop location.


Code 4 indicates an invalid message sent by server, and the write error is probably no disk space on the server, or either may be the server limits of data was exceeded.