When connection fails it hangs.. when connection is good it is good.On Testsystem Connect() Hangs... never returns

Nov 7, 2012 at 5:28 PM

When the connection fails the program just hangs in the Connect() method, nothing is triggered.

The code snippet followed by the trace is below.  The trace looks like its in an infinite loop! Please help I need this very, very soon.

//code snippet
private void Connect2FTP()
        {
           
            ConnectionInfo conn= new ConnectionInfo(host, port, user, 
                                                new PasswordAuthenticationMethod(user, pwd),
                                                new PrivateKeyAuthenticationMethod(user, new PrivateKeyFile(ssh_privatekey, passphrase))
                                                );

            //new PrivateKeyFile(privatekey, passphrase);
            sftp = new SftpClient(conn);
            sftp.ErrorOccurred += new EventHandler(sftp_ErrorOccurred);
 
            sftp.ConnectionInfo.RetryAttempts = 0;
           
            //sftp.ConnectionInfo.Timeout = TimeSpan.FromSeconds(10);
            //sftp.OperationTimeout = TimeSpan.FromSeconds(10);
            
            try
            {
                
                sftp.Connect();  //When the connection info is no good it just hangs here for ever
     //the ErrorOccured isnt triggered, nothing happens just hangs
     //see trace below
     //when  it gets connected it proceeds to other places....
            }

Below is the trace:

System.Net.Sockets Verbose: 0 : [3740] DNS::GetHostAddresses(orbitalbatch.paymentech.net)
System.Net.Sockets Verbose: 0 : [3740] DNS::GetHostByName(orbitalbatch.paymentech.net)
System.Net Information: 0 : [3740] Current OS installation type is 'Client'.
System.Net.Sockets Verbose: 0 : [3740] Exiting DNS::GetHostByName()  -> IPHostEntry#41300193
System.Net.Sockets Verbose: 0 : [3740] Exiting DNS::GetHostAddresses()  -> IPAddress[]#15586314
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Socket(InterNetwork#2)
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::Socket()
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::BeginConnect(133:22#-2059771878)
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::BeginConnect()  -> ConnectAsyncResult#12781633
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::EndConnect(ConnectAsyncResult#12781633)
System.Net.Sockets Information: 0 : [3740] Socket#35059110 - Created connection from 192.168.90.13:64605 to 12.96.58.133:22.
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::EndConnect()
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Receive()
System.Net.Sockets Verbose: 0 : [3740] Data from Socket#35059110::Receive
System.Net.Sockets Verbose: 0 : [3740] 00000000 :                                                 :
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::Receive()  -> 0#0
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Receive()
System.Net.Sockets Verbose: 0 : [3740] Data from Socket#35059110::Receive
System.Net.Sockets Verbose: 0 : [3740] 00000000 :                                                 :
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::Receive()  -> 0#0
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Receive()
System.Net.Sockets Verbose: 0 : [3740] Data from Socket#35059110::Receive
System.Net.Sockets Verbose: 0 : [3740] 00000000 :                                                 :
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::Receive()  -> 0#0
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Receive()
System.Net.Sockets Verbose: 0 : [3740] Data from Socket#35059110::Receive
System.Net.Sockets Verbose: 0 : [3740] 00000000 :                                                 :
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::Receive()  -> 0#0
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Receive()
System.Net.Sockets Verbose: 0 : [3740] Data from Socket#35059110::Receive
System.Net.Sockets Verbose: 0 : [3740] 00000000 :                                                 :
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::Receive()  -> 0#0
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Receive()
System.Net.Sockets Verbose: 0 : [3740] Data from Socket#35059110::Receive
System.Net.Sockets Verbose: 0 : [3740] 00000000 :                                                 :
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::Receive()  -> 0#0
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Receive()
System.Net.Sockets Verbose: 0 : [3740] Data from Socket#35059110::Receive
System.Net.Sockets Verbose: 0 : [3740] 00000000 :                                                 :
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::Receive()  -> 0#0
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Receive()
System.Net.Sockets Verbose: 0 : [3740] Data from Socket#35059110::Receive
System.Net.Sockets Verbose: 0 : [3740] 00000000 :                                                 :
System.Net.Sockets Verbose: 0 : [3740] Exiting Socket#35059110::Receive()  -> 0#0
System.Net.Sockets Verbose: 0 : [3740] Socket#35059110::Receive()