Hortonworks webhdfs i try to list all folder it will work on Hortonworks console using curl command but not in C#

117 views Asked by At

I try to list the name of the folder using webhdfs in C#. URL working fine using curl in sandbox but not in C# in my laptop

Error Message- SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Code:

static void Main(string[] args)
{
    Uri myUri = new Uri("http://hostname:50070/webhdfs/v1/user/hive/warehouse");
    string userName = "myuser";

    WebHDFSClient hdfsClient = new WebHDFSClient(myUri, userName);
    string strDirectoryPath= "/user/hive/warehouse";
    ArrayList l = new ArrayList();
    l.Add(hdfsClient.GetDirectoryStatus(
      strDirectoryPath).Result.Directories);
}
1

There are 1 answers

0
Doron Veeder On

few issues:

  1. your URI is "http://hostname:50070/webhdfs/v1/user/hive/warehouse", and your strDirectoryPath= "/user/hive/warehouse" - so your duplicating the path to be "http://hostname:50070/webhdfs/v1/user/hive/warehouse/user/hive/warehouse" which does not exist
  2. you user "myuser" may not have permissions access to /user/hive/warehouse - check its permissions by "hdfs dfs -ls /user/hive/warehouse"
  3. (just checking) the 'hostname' in the URI - is just for the question and not in the actual code, right? you'll need the hostname/ip of the sandbox