Element session@0 already read to the end Source

Advertisement

shailu0287
Joined:
Posts:
2
Location:
india

Element session@0 already read to the end Source

I am trying to upload files using the WinSCP C# library on FTP. I am getting the following error randomly:
Element session@0 already read to the end Source
Sometimes my code works fine sometimes I do get this error. Currently, I am using the 5.19.6 version the of WinSCP library.

Any help on this would be appreciated.

Thanks in advance.

Reply with quote

Advertisement

shailu0287
Joined:
Posts:
2
Location:
india

This is the code for creating session.

private SessionOptions GetSessionOptions(string password)
{
  // Setup session options
  var sessionOptions = new SessionOptions
  {
    Protocol = (this._ftpType == FtpType.ActiveFTP || this._ftpType == FtpType.PassiveFTP)
      ? Protocol.Ftp
      : Protocol.Sftp,
    HostName = this._host,
    UserName = this._userName,
    Password = password,
    PortNumber = this._port,
    FtpMode = this._ftpType == FtpType.ActiveFTP ? FtpMode.Active : FtpMode.Passive,
    SshHostKeyPolicy = this._ftpType == FtpType.SFTP ? SshHostKeyPolicy.AcceptNew : SshHostKeyPolicy.Check
  };
 
  if (sessionOptions.Protocol == Protocol.Sftp && !string.IsNullOrEmpty(this._privateKeyFile))
  {
    sessionOptions.SshPrivateKeyPath = this._privateKeyFile;
  }
 
  return sessionOptions;
}

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,453
Location:
Prague, Czechia

Re: Element session@0 already read to the end Source

Set Session.SessionLogPath and Session.DebugLogPath and post both logs (using the latest version of WinSCP).

Reply with quote

Advertisement

You can post new topics in this forum