CONNECTING to SFTP (SSH2) enable server getting System.Net.Sockets.SocketException

Feb 7, 2013 at 1:57 AM
Can anybody please help! Here is the message I got when trying to connect. Here is my code:

class Program
{
    static string ip = "10.48.174.23", user = "SD_DCFS", pass = "SDdcfs_EFT";
    static int port = 22;       

    static void Main(string[] args)
    {
        SftpClient sftp = new SftpClient(ip, port, user, pass);
        sftp.Connect();            
         SshNET.Uploader(sftp, inFilePath, directoryPath, "Test.txt");
         sftp.Disconnect();
    }
 }
and here is the message I received:

System.Net.Sockets.SocketException was unhandled
Message=A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.48.174.23:22
Source=System
ErrorCode=10060
NativeErrorCode=10060
StackTrace:
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at Renci.SshNet.Session.SocketConnect(String host, Int32 port)
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.Connect()
   at FTP_LAUSD.Program.Main(String[] args) in \\isdowfsv03\d350home\e542938\visual studio 2010\Projects\FTP_LAUSD\Program.cs:line 28
InnerException:

Thanks,
-bill
Coordinator
Feb 7, 2013 at 2:25 PM
Hi,

You getting this error because client could not connect to the server.
Are you able to connect to it using other software?
This is more network issue it seems.

Hope it helps,
Thanks,
Oleg
Feb 7, 2013 at 6:18 PM
Hi Oleg,

You'are absolutely right. I used the wrong IP so I wasn't able to connect. I have another quesiton. Do you have example that I can upload a DataTable instead of a text file?

Thank you so much,
-bill
Coordinator
Feb 7, 2013 at 6:21 PM
Hi,

No, Sorry, I do not have such example.

Thanks,
Oleg
Feb 7, 2013 at 6:37 PM
Hi Oleg,

Can I write the DataTable to a MemoryStream and then upload the MemoryStream using sftpClient.UploadFile()?

Thanks,
-bill
Coordinator
Feb 7, 2013 at 7:57 PM
Hi,
I am sure its possible,
You can find examples of it online since its not SSH specific task.

Thanks,
Oleg