0 votes
by (900 points)

How to find servers are FXP support or not Support ?

Is there any command, any function in Rebex.ftp, any workaround?

Applies to: Rebex FTP/SSL

1 Answer

+1 vote
by (58.9k points)
selected by
 
Best answer

The server-to-server (so called "FXP") feature is part of the FTP protocol. When the FTP protocol was designed no one thought that FTP server administrators will be disabling this feature and thus there is no official way to determine whether this is supported by your server in the FTP protocol. The simple test is to upload a small file to the primary server and then try the FXP transfer. Here is a code that tests whether your FTP servers support it:

    bool IsFXPTransferSupported()
    {
        string primaryServerDest =  "/Incoming1/small-test-file.txt";
        string secondaryServerDest = "/Incoming2/small-test-file.txt";

        Ftp ftp1 = new Ftp();
        ftp1.Connect("server1");
        ftp1.Login("user1", "password1");

        Ftp ftp2 = new Ftp();
        ftp2.Connect("server2");
        ftp2.Login("user2", "password2");

        // upload small test file to the primary FTP server
        string testFileContent = "this is a test file";
        var ms = new MemoryStream(Encoding.ASCII.GetBytes(testFileContent));
        ftp1.PutFile(ms, primaryServerDest);

        // try performing the server-to-server FXP transfer
        try
        {
            ftp1.CopyToAnotherServer(ftp2, primaryServerDest, secondaryServerDest);
        }
        catch (NetworkSessionException ex)
        {
            return false;
        }

        return true;
    }
...