Reputation: 709
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.
Upvotes: 0
Views: 2700
Reputation: 4950
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))
Upvotes: 1