Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"The requested name is valid, but no data of the requested type was found" when connecting to SFTP with SharpSsh

Tags:

c#

sftp

sharpssh

I have to download some files from a SFTP location.

I am using the SharpSsh libraries but I am unable to connect.

Below are my SFTP details :

<add key="FTPHost" value="xyz.csod.com" />
<add key="FTPDirectory" value="/Test" />
<add key="FTPUserName" value="abc" />
<add key="FTPPassword" value="pass" />
<add key="FTPPort" value="22" />

And below is piece of code of c# to connect with SFTP :

using Tamir.SharpSsh;
using Tamir.SharpSsh.jsch;
using Tamir.Streams;

public string DownloadFile()
{                       
        Sftp oSftp = new Sftp(host, userName, password);//
        oSftp.Connect(port);
}

But I am getting exception at Connect().Is -

Additional information:

System.Net.Sockets.SocketException (0x80004005): The requested name is valid, but no data of the requested type was found

System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6) at System.Net.Dns.GetHostByName(String hostName) at Tamir.SharpSsh.java.net.Socket..ctor(String host, Int32 port) at Tamir.SharpSsh.jsch.Util.createSocket(String host, Int32 port, Int32 timeout)"

I am working with C# console application.

like image 962
Pawan Agrawal Avatar asked Apr 09 '15 06:04

Pawan Agrawal


1 Answers

You can see that is something wrong with your DNS issue. As exception throwing is a related with Win socket.

See following link for different kind of exceptions and meaning of exception related to windows socket.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx#WSANO_DATA

Also I try to ping that domain which you asked in question and It's saying request timeout. So there must be something wrong with DNS.

If you have IP Address of this then try with IP and See are you able to connect on it.

Also make sure that. You have properly setup SFTP there on the server where you are trying to connect.

Also try to connect to there some server with some FTP client like filezilla or any other. If you are able to connect then there is a problem of code otherwise it is something related setup of STFP

Hope this will help you.

like image 150
Jalpesh Vadgama Avatar answered Sep 20 '22 03:09

Jalpesh Vadgama