Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Problem to connect using the PROXY Squid

$
0
0
using System;
using Renci.SshNet;

namespace ConsoleApplication1
{
class Program
{
    static void Main(string[] args)
    {

        const string host = "demo.wftpserver.com";
        const int port = 2222;
        const string userName = "demo-user";
        const string password = "demo-user";

        const ProxyTypes pType = ProxyTypes.Http;
        const string pHost = "127.0.0.1";
        const int pPort = 3128;

        var sFtp_Autentication = new PasswordAuthenticationMethod(userName, password);

        var connectInfo = new ConnectionInfo(host, port, userName, pType, pHost, pPort, "", "", sFtp_Autentication);

        //var connectInfo = new ConnectionInfo(host, port,userName,  sFtp_Autentication);

        Console.WriteLine("Creating client and connecting");
        Console.WriteLine(host);

        using (SftpClient client = new SftpClient(connectInfo))
        {
            try
            {
                client.OperationTimeout = new TimeSpan(0, 0, 30);
                client.Connect();
            }
            catch (Exception exe)
            {
                Console.WriteLine(exe.ToString());
            }
            if (client.IsConnected)
            {
                Console.WriteLine("Connected to {0}", host);
                var ls = client.ListDirectory(".");
                foreach (var s in ls)
                {
                    Console.WriteLine(s);
                }
            }
            else
                Console.Write("Not Connected");


            Console.Read();
        }

    }
}

}

_Connect ok using:

var connectInfo = new ConnectionInfo(host, port,userName, sFtp_Autentication);

Creating client and connecting
demo.wftpserver.com
Connected to demo.wftpserver.com
Name You can upload file into [upload], Length 34, User ID 0, Group ID 0, Access
ed 19/09/2013 9:27:44, Modified 08/08/2013 9:23:27
Name download, Length 4096, User ID 0, Group ID 0, Accessed 22/09/2013 4:56:11,
Modified 07/08/2013 18:05:06
Name upload, Length 20480, User ID 0, Group ID 0, Accessed 23/09/2013 3:08:00, M
odified 23/09/2013 7:22:03

_Not Connect using:
 var connectInfo = new ConnectionInfo(host, port, userName, pType, pHost, pPort, "", "", sFtp_Autentication);
_Mensage with Proxy port 2222 worked and allowed (not OK):

Creating client and connecting
demo.wftpserver.com
Renci.SshNet.Common.SshOperationTimeoutException: Socket read operation has time
d out
en Renci.SshNet.Session.SocketReadLine(String& response)
en Renci.SshNet.Session.ConnectHttp()
en Renci.SshNet.Session.Connect()
en Renci.SshNet.BaseClient.Connect()
en ConsoleApplication1.Program.Main(String[] args) en c:\users\manuel\documen
ts\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.c
s:línea 34
Not Connected


_Message if the proxy is stopped (is OK):

Creating client and connecting
demo.wftpserver.com
System.Net.Sockets.SocketException (0x80004005): No se puede establecer una cone
xión ya que el equipo de destino denegó expresamente dicha conexión 127.0.0.1:31
28
en System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
en Renci.SshNet.Session.SocketConnect(String host, Int32 port)
en Renci.SshNet.Session.Connect()
en Renci.SshNet.BaseClient.Connect()
en ConsoleApplication1.Program.Main(String[] args) en c:\users\manuel\documen
ts\visual studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.c
s:línea 34
Not Connected


_Thanks for your help.

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>