Quantcast
Channel: Rebex Q&A Forum - Recent questions and answers
Viewing all articles
Browse latest Browse all 3862

The connection was closed by the server. Make sure you are connecting to an SSH or SFTP server

$
0
0

We've been using Rebex for SFTP connections for 10 years and it works great.
Recently, we've updated our old version (2012) to R6.4, and later to R6.9
Since then, our customers are experiencing some problems, where out of the blue the communication fails, or there are some problems establishing communication.

The error seem to be "The connection was closed by the server. Make sure you are connecting to an SSH or SFTP server"

Our customers use our IDE for programming a PLC that has an SFTP server on it, and in the test case, it is connected to the PC using a USB cable.

I have made some code example:
a Console application in C# that opens new connections:

static void Main(string[] args)
    {
        int success = 0;
        Stopwatch sw = new Stopwatch();
        sw.Start();
        for (int i = 0; i < 1000; i++)
        {
            Sftp sftp = new Sftp();
            try
            {
                sftp.Connect("169.254.100.1", 22);
                Console.WriteLine(true);
                success++;
                //sftp.Disconnect();
                //sftp.Dispose();
            }
            catch
            {
                Console.WriteLine(false);
                sftp.Disconnect();
                sftp.Dispose();
            }
            System.Threading.Thread.Sleep(100);
        }

        sw.Stop();

        Console.WriteLine($"Total Time: {sw.ElapsedMilliseconds}");
        Console.WriteLine($"Success: {success}/1000");
        Console.ReadLine();
    }

If I run this example with Rebex 2012, then there is a 95% success

If I run the same example with Rebex 2022 (R6.9), I get 54% success. I see the connect method connects much faster in R6.9 (compared to 2012), and it looks like it's reusing sockets or some resources.

If I uncomment the 2 rows of sftp.Disconnect() and sftp.Dispose() (the dispose has no effect to the results, and Disconnect makes all the difference), then the success goes up to 99% and even 100% with R6.9, and I also notice that Connect() is now slower (it takes more time to connect)

I'm creating new instances of the new sftp client, so there shouldn't be any "leak" between them, however it seems there is some.

Just to be clear. My actual code does disconnect the sftp connection when it done, and there was some place in the code that didn't had it (recently added) and it was opening and closing connections frequently, but even after fixing this issue, I'm still able to reproduce the issue on our IDE (The code cannot be shared since it has millions lines of code).

Using the same IDE with Rebex 2012 dlls produces a stable connection, while with R6.9 there are times where connection to the server fails with the error above, and sometimes in the middle of the transfer the communication fails with that error, and when the code tries to open a new connection (for retries) it fails again.

Can you assist?

10x


Viewing all articles
Browse latest Browse all 3862

Trending Articles