Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
43 views
ago in .NET FTP by (140 points)

I've seen a few posts from years ago, but I haven't seen anything recent. What am I missing? Connecting to a simple sFTP server with user/password auth, and I can list files in a directory. But when I try to check if a file exists, I receive the error that "The FTP client has not yet connected to the server.  The requested action cannot be performed until after a connection has been established."

This did not happen in the previous version I was using, 10.1. It only happened once I moved to the latest version, 12.5.0.

sftp.Connect();
var remoteFiles = sftp.ListDirectory(dataDirectory);
foreach (FTPFile remoteFile in remoteFiles)
{
    if (remoteFile.Dir)
        continue;
    // check if this file is already in another directory
    string anotherName = OtherDirectoryName + remoteFile.Name;
    if (sftp.Exists(
anotherName ))   <<<<<< problem here

EnterpriseDT.Net.Ftp.FTPException
  HResult=0x80131600
  Message=The FTP client has not yet connected to the server.  The requested action cannot be performed until after a connection has been established.
  Source=edtFTPnetPRO
  StackTrace:
   at EnterpriseDT.Net.Ftp.FTPClient.pE4vf83jcr(Boolean  )
   at EnterpriseDT.Net.Ftp.FTPClient.Exists(String remoteFile)
   at EnterpriseDT.Net.Ftp.FTPConnection.Exists(String remoteFile)

The FTP component is setup with a username and password.

Protocol = FileTransferProtocol.SFTP,

ServerValidation = SecureFTPServerValidationType.None,
 

Log (I hope the relevant sections - I'm limited in what I can post)

DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.159 :  User authentication successful
......
DEBUG [SSHFTPClient] 18 Aug 2025 01:25:13.437 :  Set transfer type = BINARY
DEBUG [FTPConnection] 18 Aug 2025 01:25:13.437 :  Home directory is '/home/user'
DEBUG [FTPConnection] 18 Aug 2025 01:25:13.437 :  GetFileInfos('/home/user/data_qa/')
DEBUG [SSHFTPClient] 18 Aug 2025 01:25:13.437 :  ResolveRemotePath('/home/user/data_qa/'); [cwd='/home/user']
DEBUG [SSHFTPClient] 18 Aug 2025 01:25:13.437 :  Resolved to '/home/user/data_qa'
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.437 :  Send : Name=SSH_FXP_REALPATH,Type=16,RequestID=2
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.437 :  Transmit 46 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.437 :  Remote window size decreased to 2097083
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.437 :  Sent 84 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.437 :  Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.484 : FTPConnection.12 RepeatCallback received 132 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.484 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.484 : FTPConnection.12 CreateMessage (bufferlength=100,offset=13,length=87,type=104)
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.484 : FTPConnection.12 SSH_FXP_NAME: requestID=2, 1 files
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.484 : FTPConnection.12 AddMessage(2) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.484 :  Reply : Name=SSH_FXP_NAME,Type=104,RequestID=2
DEBUG [SFTPSubsystem] 18 Aug 2025 01:25:13.484 :  Opening directory /home/user/data_qa
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.484 :  Send : Name=SSH_FXP_OPENDIR,Type=11,RequestID=3
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.484 :  Transmit 46 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.484 :  Remote window size decreased to 2097037
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.484 :  Sent 84 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.484 :  Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.531 : FTPConnection.12 RepeatCallback received 60 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.532 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.532 : FTPConnection.12 CreateMessage (bufferlength=26,offset=13,length=13,type=102)
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.532 : FTPConnection.12 AddMessage(3) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.532 :  Reply : Name=SSH_FXP_HANDLE,Type=102,RequestID=3
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.532 :  Send : Name=SSH_FXP_READDIR,Type=12,RequestID=4
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.532 :  Transmit 17 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.532 :  Remote window size decreased to 2097020
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.533 :  Sent 60 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.533 :  Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.582 : FTPConnection.12 RepeatCallback received 7676 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.582 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.582 : FTPConnection.12 CreateMessage (bufferlength=7646,offset=13,length=7633,type=104)
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.582 : FTPConnection.12 SSH_FXP_NAME: requestID=4, 39 files
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.582 : FTPConnection.12 AddMessage(4) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.582 :  Reply : Name=SSH_FXP_NAME,Type=104,RequestID=4
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.582 :  Send : Name=SSH_FXP_READDIR,Type=12,RequestID=5
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.582 :  Transmit 17 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.582 :  Remote window size decreased to 2097003
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.582 :  Sent 60 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.583 :  Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.623 : FTPConnection.12 RepeatCallback received 76 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.623 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.623 : FTPConnection.12 CreateMessage (bufferlength=41,offset=13,length=28,type=101)
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.623 : FTPConnection.12 ErrorCode|Status=1
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.623 : FTPConnection.12 AddMessage(5) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.623 :  Reply : Name=SSH_FXP_STATUS,Type=101,RequestID=5
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.623 :  Send : Name=SSH_FXP_CLOSE,Type=4,RequestID=6
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.623 :  Transmit 17 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.623 :  Remote window size decreased to 2096986
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.623 :  Sent 60 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.623 :  Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.667 : FTPConnection.12 RepeatCallback received 68 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.667 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.667 : FTPConnection.12 CreateMessage (bufferlength=37,offset=13,length=24,type=101)
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.667 : FTPConnection.12 ErrorCode|Status=0
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.667 : FTPConnection.12 AddMessage(6) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.667 :  Reply : Name=SSH_FXP_STATUS,Type=101,RequestID=6
DEBUG [FTPConnection] 18 Aug 2025 01:25:15.785 :  Exists(/home/user/data_qa/processed/checkfile.zip)

 

ago by (165k points)
It looks to me like the server has disconnected the client - is it possible to obtain the server log?
ago by (140 points)
I ran another test this morning, to isolate the chatter. It's extremely basic, and looks like it doesn't even receive anything related to the Exists() call.

Aug 18 13:18:29 ip-server-ip sftp-server[12342]: session opened for local user user from [remote.ip]
Aug 18 13:18:29 ip-server-ip sftp-server[12342]: received client version 3
Aug 18 13:18:29 ip-server-ip sftp-server[12342]: realpath "."
Aug 18 13:18:29 ip-server-ip sftp-server[12342]: realpath "/home/user/data_qa"
Aug 18 13:18:29 ip-server-ip sftp-server[12342]: opendir "/home/user/data_qa"
Aug 18 13:18:30 ip-server-ip sftp-server[12342]: closedir "/home/user/data_qa"
Aug 18 13:21:32 ip-server-ip sftp-server[16734]: session closed for local user user from [remote.ip]
ago by (165k points)
Hmm, it just says "session closed" but doesn't explain why that happened. There's no call to the exists method because it checks if the connection is open before calling it.
ago by (140 points)
That "session closed" was 3 minutes later, well after I would have encountered the error. I hit the error a couple of seconds - I was debugging - after I received the directory listing. So the connection still would have been active.

This works:
    sftp.Connect();
    var remoteFiles = sftp.ListDirectory(dataDirectory);

This does not work:
    sftp.Connect();
    var exists = sftp.Exists("gabba_gabba_hey");

I hit the exact same error. This really makes me think it's something the Exists() call is doing and not the server.

I do have to correct one thing I said in my original post. I reverted to version 10.1, and the error still occurs. This is a different area of my code than I was thinking of when I wrote the original post.
ago by (165k points)
This is getting beyond a public forum post. Please open a ticket and include your log file and as much information as possible.

https://enterprisedt.atlassian.net/servicedesk/customer/portal/1

Please log in or register to answer this question.

Categories

...