0 votes
by (120 points)

We host our .NET 5 APP in a Azure Service fabric cluster.
We have open port 22 to the cluster

But we cant reach the SFTP. Connection times out

Anyone have experience hosting this library in Azure Service Fabric?

enter image description here

Applies to: Rebex SFTP

1 Answer

0 votes
by (148k points)

We are not aware of anyone using Rebex SFTP libraries in Azure Service Fabric, but we are not aware of any issues either. Are you able to use .NET's System.Net.Sockets.Socket class to establish a connection to port 22 of a remote server? That's what Rebex SFTP uses for communication. If you are, please create a communication log using Sftp object's LogWriter property and post it here or mail it to us for analysis (or implement a custom logger based on LogWriterBase class in case this Azure environment lacks a file system.

by (120 points)
Hi, thanks for reply. Trying with a socket I get this when doign it local

Socket connected to -> 127.0.0.1:22
Message from Server -> SSH-2.0-RebexSSH_5.0.8123.0

When doing it against azure I get a timeout when calling Connect
by (148k points)
I thought you were using the client-side 'Sftp' class, but you are actually using the server-side 'FileServer' class - is this correct? Do you bind the port by calling FileServer object's Bind(22, FileServerProtocol.Sftp) method? If that's the case, then the issue is likely to be caused by some peculiarity of Azure Service Fabric.

According to https://cuteprogramming.wordpress.com/2018/09/13/tcp-listener-on-microsoft-azure-with-service-fabric/ it looks like getting TCP listener to work on this platform requires some additional work beyond simply starting a listener socket, which is what FileServer class does. Are you able to connect to a TCP server if you set it up according to that article?
by (120 points)
I also found that article last week. I have added a endpoint at port 22 but. The listener stuff I havent tried since I cant use it with your library. Put I could test that code and see if I can connect,.
by (148k points)
Please do give it a try!
It's possible to launch an SFTP/SSH session on an already-connected Socket, so if you can get that code to work, then instead of calling "client.GetStream" (as in the article's example code), you could start a FileServer session on "client.Socket" using the following helper class that extends FileServer:

public class FileServerExt : FileServer
{
    private ServerModuleHost _host;

    public void Accept(Socket socket)
    {
        var host = _host;
        if (host == null)
        {
            // Optionally, enable more modules in the CreateModuleHost call in addition to SFTP.
            _host = host = CreateModuleHost(FileServerProtocol.Sftp);
        }
        host.Accept(socket);
    }
}
by (120 points)
I got this to work finally. You do not need a custom TcpListener. You can use your FileServer class out of the box  After you have fixed the enpoint and configured in the Stateless service correctly and configured the load balancer (This was the step we missed we had oonly opened the firewall, see my initial post).
by (148k points)
Thanks for the update! Good to know there is a way to make it work.
...