Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Error: WinSCP.SessionRemoteException: Network error: Connection to "IP-address" timed out.

And can you connect to that IP address using any GUI/commandline SFTP client application running on the same machine, where your C# code it failing? If you can, post its log file and session log file from your C# code.
rohiniagalave

Error: WinSCP.SessionRemoteException: Network error: Connection to "IP-address" timed out.

Hi Team,

I am trying to upload a file using SFTP through C# code.
Below code I have written,
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Sftp,
    HostName = "",
    UserName = "",
    Password = "",
    PortNumber = 2222,
    SshHostKeyFingerprint = ""
};
 
using (Session session = new Session())
{
    session.ReconnectTime = new TimeSpan(0, 0, 30);
    // Connect
    session.Open(sessionOptions);
 
    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Binary;
 
    TransferEventArgs transferResult;
    transferResult =
        session.PutFileToDirectory(@"C:\Users\rohiniag\Desktop\DemoPDF2.pdf", @"\SFTFIIles\", false, transferOptions);
    Console.WriteLine(transferResult.Touch);
 
}

Giving me
Network error : connection time out

Attached screenshot of it. Please help me out.