sftp behind proxy unable to connect

Nov 29, 2013 at 7:04 AM
Hi Guys,

this may sound familiar but I am unable to get it to connect:

Exception:
at Renci.SshNet.Session.SocketReadLine(String& response)
at Renci.SshNet.Session.ConnectHttp()
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at FTPClient.ArchitasSFTPClient.DownLoadFiles() in c:\SFTPClient.cs:line 134
at FTPClientConsoleApp.Program.Main(String[] args) in c:\FTPClientConsoleApp\Program.cs:line 228
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

and the code is:

var connectionInfoz = new ConnectionInfo(_ftpServer, PORT, _userName,
            ProxyTypes.Http, PROXYHOST, PROXY_PORT, _userName, _password,
            new AuthenticationMethod[] { new PasswordAuthenticationMethod(_userName, _password) })
            {
                Timeout = TimeSpan.FromMinutes(15)
            };

        using (var sftp = new SftpClient(connectionInfoz))
        {
            sftp.BufferSize = 1024;
            sftp.ConnectionInfo.Timeout = TimeSpan.FromMinutes(3);
            sftp.OperationTimeout = TimeSpan.FromMinutes(10);
            try
            {
                sftp.KeepAliveInterval = TimeSpan.FromMinutes(10);
                var connectionInfo = sftp.ConnectionInfo;
                Console.WriteLine(connectionInfo.Timeout);
                sftp.Connect(); // this line throws exception after waiting for 3 minutes

            }

            catch (ProxyException ex)
            {
                Console.WriteLine(ex.Message);
            }
}

I can connect to the site via WinSCP without any problems.
Dec 3, 2013 at 10:42 AM
ok,

I've got a bit more information, the sockets are getting blanks and the connect method is stuck in this loop:

System.Net.Sockets Verbose: 0 : [6392] Exiting Socket#51791499::BeginReceive() -> OverlappedAsyncResult#15796147
System.Net.Sockets Verbose: 0 : [6392] Socket#51791499::EndReceive(OverlappedAsyncResult#15796147)
System.Net.Sockets Verbose: 0 : [6392] Exiting Socket#51791499::EndReceive() -> Int32#0
System.Net.Sockets Verbose: 0 : [6392] Socket#51791499::BeginReceive()
System.Net.Sockets Verbose: 0 : [7256] Data from Socket#51791499::PostCompletion
System.Net.Sockets Verbose: 0 : [7256] 00000000 : :
System.Net.Sockets Verbose: 0 : [6392] Exiting Socket#51791499::BeginReceive() -> OverlappedAsyncResult#39737976
System.Net.Sockets Verbose: 0 : [6392] Socket#51791499::EndReceive(OverlappedAsyncResult#39737976)
System.Net.Sockets Verbose: 0 : [6392] Exiting Socket#51791499::EndReceive() -> Int32#0
System.Net.Sockets Verbose: 0 : [6392] Socket#51791499::BeginReceive()
System.Net.Sockets Verbose: 0 : [7256] Data from Socket#51791499::PostCompletion
System.Net.Sockets Verbose: 0 : [7256] 00000000 : :
System.Net.Sockets Verbose: 0 : [6392] Exiting Socket#51791499::BeginReceive() -> OverlappedAsyncResult#43378475
System.Net.Sockets Verbose: 0 : [6392] Socket#51791499::EndReceive(OverlappedAsyncResult#43378475)
System.Net.Sockets Verbose: 0 : [6392] Exiting Socket#51791499::EndReceive() -> Int32#0
System.Net.Sockets Verbose: 0 : [6392] Socket#51791499::BeginReceive()
System.Net.Sockets Verbose: 0 : [7256] Data from Socket#51791499::PostCompletion
System.Net.Sockets Verbose: 0 : [7256] 00000000 : :
System.Net.Sockets Verbose: 0 : [6392] Exiting Socket#51791499::BeginReceive() -> OverlappedAsyncResult#5874319
System.Net.Sockets Verbose: 0 : [6392] Socket#51791499::EndReceive(OverlappedAsyncResult#5874319)
System.Net.Sockets Verbose: 0 : [6392] Exiting Socket#51791499::EndReceive() -> Int32#0
System.Net.Sockets Verbose: 0 : [6392] Socket#51791499::BeginReceive()
System.Net.Sockets Verbose: 0 : [7256] Data from Socket#51791499::PostCompletion
System.Net.Sockets Verbose: 0 : [7256] 00000000 :

Any help would be massively appreciated