0

I have written a SFTP connection, which is connecting to a secure domain host (MBox location) in .NET Core:

IPHostEntry ip = Dns.GetHostEntry(Host);

using (SftpClient client = new SftpClient(ip.ToString(), Port, User, Password))
{
    //connect to client
    client.Connect();
    var files = client.ListDirectory(PathToRead).ToList();
    ......
    //wait for downloads to finish
    await Task.WhenAll(tasks);

    // disconnect the client by closing connection
    client.Disconnect();
}

which is hosted in Azure App service with subscription and Azure AD configured as per my client's domain. When I am running the code I am seeing the following error:

Error in FTP connection. Exception: System.Net.Sockets.SocketException (11001): No such host is known

Can you please help.

0

1 Answer 1

1

ip.ToString() returns the name of the type, System.Net.IPHostEntry. Your SftpClient is then trying to look up System.Net.IPHostEntry in DNS and not finding anything, thus the exception.

I'm not familiar with the constructors provided by SftpClient, but presumably you need to do something like:

using (SftpClient client = new SftpClient(ip.AddressList, Port, User, Password))
Sign up to request clarification or add additional context in comments.

2 Comments

Or simply new SftpClient(Host, Port, User, Password).
sorry guys, nothing is working, I think, I have to append the sFTP host IP with domain white-list, still searching

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.